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 trialAlexisca hall
23,683 PointsIn 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
Treehouse TeacherHi 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!
Alexander Davison
65,469 PointsYour variable name is theisWinner
, but the challenge wants you to call it isWinner
.
Fiodar Shkolnikau
3,426 Pointslet 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
Treehouse TeacherThe 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).
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsMy last name is Davison and not Davidson, just FYI.
Great Answer!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherSorry, Alexander. I'm correcting that now
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsIt's ok People make that mistake all the time