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 trialMatt Sousa
6,799 PointsDeclare a var.... Make sure its a let ?
In this code challenge I am asked to make a variable named isWinner and to assign it to the value of NOT 10
"Declare a variable named isWinner and assign the results of a comparison operation to check whether the player has won or not. If the total score is not 10, then the player has won, otherwise he or she has lost. (Hint: Use the NOT operator)"
When I tried to set the isWinner var to != 10 I am greeted with this compiler error,
" Bummer! Make sure you're using the NOT operator to make a comparison and assign the results to a constant named isWinner"
I am confused as to what to try next, or maybe I just completely overlooked my problem, can anyone help?
// Enter your code below
var initialScore = 8
let totalScore = ++initialScore
var isWinner != 10
3 Answers
Richard Lu
20,185 PointsHey Matt,
The question ask you to assign isWinner a true or false value determined by the following statement:
"If the total score is not 10, then the player has won, otherwise he or she has lost."
With that being said, you can approach the problem like this:
var isWinner = (totalScore != 10) // if the total score is not 10, the player has won (true)
Jacqueline Boltik
Courses Plus Student 11,153 PointsHere's the answer that worked for me
var initialScore = 8
initialScore += 1
let isWinner = (initialScore != 10)
CARLOS MATTHEWS
1,041 Pointsvar initialScore = 8
initialScore += 1
let totalScore = initialScore
var isWinner = (totalScore != 10)
Matt Sousa
6,799 PointsMatt Sousa
6,799 PointsI feel the wording is a little bland to describe this to be a true or false value, but I can see that, this is what it is asking. The code solved my problem, thank you.