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 Basics Swift Operators Working With Operators: Part 2

In this game of ours, we have an odd scoring mechanism . At the end of the round, if your score is 10, you lose! If it's

how to solve this

// Enter your code below
var initialScore = 8
initialScore += 1
let theisWinner = score != 10

3 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi Alexisca! I received your request for assistance. I'm not sure exactly why Alexander Davison was down voted, but he is at least partially correct. Challenges can be incredibly strict as they are checking for very specific things. And the challenge explicitly asks you to use the variable isWinner. Note that even the capitalization here must be correct or it will still fail the challenge.

But there's an additional problem with your code. The reason you're getting a compiler error is because the variable score was never defined. We've only ever defined initialScore. Take a look at this quote from the first step of the challenge:

In the editor, initialScore represents a user's score in a game.

Your comparison should be comparing if initialScore is not equal to 10. So, if I change theisWinner to isWinner and score to initialScore, your code passes with flying colors!

Try making these changes in the challenge and it should pass. If you're still stuck, please don't hesitate to write back! :sparkles:

My last name is Davison and not Davidson, just FYI.

Great Answer!

It's ok :smiley: People make that mistake all the time :laughing:

Your variable name is theisWinner, but the challenge wants you to call it isWinner.

let isWinner = initialScore != 10 isWinner == true

What you basically are doing here is assigning the constant isWinner to initialScore != 10 like it says in the challenge description. If the score is nothing but 10 you win. Since isWinner = initialScore != 10 we can then type out isWinner as true with the equals equals operator.

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

The isWinner == true that you've listed above will do nothing. This is a comparison that will return a boolean value but will never be used nor stored anywhere (at least given your code).