-1

Here is the code:

let answer = randomIntBetween(1, high: 100)

print("Enter a number between 1 and 100!")

let userInput = input()
let inputAsInt = userInput.toInt()

if let guess = inputAsInt {
if (guess > answer) {
    print("Your guess was too high!")
} else if (guess < answer) {
    print("Your guess was too low!")
} else {
    print("You got it dead on! The answer was \(answer)!")
}
} else {
print("Not a valid answer, try adding a number!")
}

I am following a guide (only been learning for about a month) and I know .toInt() was removed but what would I need to put in its place?

Nelson.J
  • 23
  • 3

1 Answers1

0

Down cast replaced it.

let inputAsInt = Int(userInput)
Dan Leonard
  • 3,325
  • 1
  • 20
  • 32