Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift 2.0 Basics Swift Operators Working With Operators: Part 2

i don't understand how to do this i tried this let totalScore = ++initialScore isWinner = totalScore!10

i also tried if statements but the editor did not accept

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! If what you posted in the question is correct, then you were very close! And you did the totalScore/initialScore incrementing correctly. The problem would be in your isWinner part.

The line you needed:

let isWinner = totalScore != 10

This will create a new constant named isWinner and set the value to the result of the comparison between totalScore and not equal to 10. So if the totalScore is 10 it will return a False and assign False to isWinner. Otherwise, the user has won the game.

Hope this helps! :sparkles:

Ben Masel
Ben Masel
2,004 Points

Hi there! Ok, so it says that you have to make a constant called isWinner and if the totalScore doesn't equal 10 you win. So the not operator is != for variables or constants and the ! is for integers. It technically says isWinner needs to equal totalScore that doesn't equal 10, so you would do: let isWinner = totalScore != 10 Hope this helps : )