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 trialVarun Kashyap Kuturu
17,963 PointsI have a problem with this question..Can anyone share their program with me? Thank you
I can't understand how to use the not operator.
// Enter your code below
var initialScore = 8
let totalScore = ++initialScore
totalScore != 10
let isWinner = true
1 Answer
Lucas Smith
11,616 PointsHi there!
With this challenge, you are wanting to determine whether or not they are a winner, by checking to see if their score is not equal to 10. There are a few more advanced ways of doing this, but the challenge is wanting you to determine this at assignment of the isWinner variable, so lets break this down a little.
We want to check totalScore against the value 10, and you have that correct in that it is:
totalScore != 10
The tricky bit is that this is happening during assignment of a bool. When evaluating an expression during assignment, the expression needs to follow the form:
/* Here I am declaring the variable as a Bool explicitly to show that it will only allow a Bool value
to be assigned to it. This doesn't have any real impact on the statement, and mostly
demonstrative in this instance */
let answer: Bool = (smallNumber != bigNumber)
For this example, if smallNumber is not equal to bigNumber, then the expression will evaluate to true, and answer will be assigned that. Now, either side of the expression, smallNumber or bigNumber, can be replaced with a literal, such as 10, and as long as they aren't equal it will evaluate to true.
I hope this makes sense! Just let me know if you have any questions, and I'll be glad to explain!
Varun Kashyap Kuturu
17,963 PointsHey, I got the answer var initailScore = 8 let totalScore = ++initialScore let isWinner = (8!=10) I tried it and I'm done with this code, the website has accepted this. Happy coding!!
Varun Kashyap Kuturu
17,963 PointsVarun Kashyap Kuturu
17,963 PointsI can't understand, what's wrong with this code..can anyone please help me?