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 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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
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 : )