Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics Swift Operators The End

Jonathan Boisvert
Jonathan Boisvert
4,582 Points

I could not figure out the syntax for getting IsWinner != 10 in the final code challenge

// I tried...

let isWinner != 10
initialscore = isWinner

3 Answers

Hi Jonathan,

From memory, and that's poor at 5:30am!, you want to assign the result of comparing initialScore to not-ten into isWinner.

So, do the comparison between initialScore to see if it is not equal to 10. Use != for that. Then put that expression to the right of an equals sign. To the left, declare the constant isWinner. Something like:

let isWinner = initialScore != 10


mohamed hassan
mohamed hassan
2,079 Points

i tried to do it another way and it went through , i dont know if it is correct or not but you guys would help increase my knowledge

let isWinner = ( initialScore < 10 )

Hi there,

Strictly, that code shouldn't pass but the challenge is clearly passing the code if isWinner holds true. Given the initial state of the game, your code does do the same thing as the 'correct' solution but it isn't quite what the instructions said to do as they wanted you to use the not operator, !.


SivaKumar Kataru
SivaKumar Kataru
2,386 Points

Jonathan ,

let initialScore: Int = 8 initialScore = initialScore + 1 // Now the value of the initial Score is 9

Now we need to create a new constant named isWinner ,which is assigned with the result of comparison expression. So we will be checking , that initial score should not be equals to 10 , if it is not then the result is TRUE . How can we do that ? so we used the LOGICAL comparison operator != to check that the intialScore value is not equals to 10 . So the syntax is

let isWinner:Bool = (initialScore != 10) // Returns Either True or False (Boolean values)

Jabes Pauya
Jabes Pauya
Courses Plus Student 2,432 Points

This is the other way mentioned by SivaKumar based on the requirements for the code syntax let isWinner: Bool = (initialScore != 10);

the other one is jonathan`s answer as let isWinner = initialScore != 10

both answer are acceptable based on my own opinion

Bernie Melo
Bernie Melo
1,539 Points

I used this: let isWinner = (initialScore != 10)