I'm having trouble with the last challenge in swift basics using the NOT operator.
I'm trying to pass the last swift basics challenge when i put in my code I get the error that my int can not be a bool value I have tried several different combinations of code but nothing seems to compute
// Enter your code below var initialScore = 8 initialScore += 1 let loose = 10 let isWinner = !10
Jason AndersTreehouse Moderator 144,810 Points
You've got the first part correct and the error you're getting for the second part isn't very explanatory, so lets have a closer look.
First, the instructions didn't say anything about creating a variable named
loose, so you've got to delete that line. Instructions will always be very specific and always need to be followed exactly. If you add something that wasn't asked for, a
Bummer! will follow.
Next, you're more or less on the right track with the
isWinner, it's just missing a little step. You need to compare the value being stored in the
initialScore to the value of
10, and then return and assign that to the variable
Right now, the code is trying to assign
!10 to the variable. There is no comparison. So, to compare, you'd need the variable being compared and the value being compared to like this:
initialScore != 10. This will return a boolean based on the comparison. Next, it needs to be assigned to the
let isWinner = initialScore != 10
Keep Coding! :)
Thanks Jason I think I did that before but I was putting my ! Before the ten not the =. your explanation really helped to sink it in. Thanks for the help :)