Your First iOS & SwiftUI App: An App from Scratch

Feb 13 2023 Swift 5.7, iOS 16, Xcode 14

Part 3: Coding in Swift

27. Variables & Constants

Episode complete

Play next episode

About this episode
See versions
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 26. Challenge: Calculate the Difference Next episode: 28. Type Inference

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Pro subscription. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

This video Variables & Constants was last updated on Feb 13 2023

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

At this point, you’ve simplified your algorithm to calculate the difference down a few lines of code.

var difference: Int = abs(target - sliderValue)
let awardedPoints: Int = 100 - difference
let awardedPoints: Int = 100 - difference
let roundedValue: Int = Int(sliderValue.rounded())
let guess = + 5
let score = game.points(sliderValue: guess)