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 trialMax Wijnschenk
497 PointsWhats wrong with my code
let isWinner != 10
// Enter your code below
var initialScore = 8
let totalScore = ++initialScore
let isWinner != 10
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Max,
You're on the right track, but the isWinner
needs to compare the totalScore
to see if it's 10 or not so it can return a Boolean value to store in isWinner
. You are using the correct operator (!=), but it's not "comparing" anything. If you were to ask yourself the question out loud -- "Does Total Score not equal 10?"
var initialScore = 8
let totalScore = ++initialScore
let isWinner = (totalScore != 10)
Keep Coding!
Tyler Andal
8,383 PointsTyler Andal
8,383 PointsTo satisfy the Working with Operators: Part 2 challenge what I put below will satisfy the challenge. var initialScore = 8 let totalScore = ++initialScore
isWinner is outstide of the scope of what is being validated in the lesson. If you are getting an error in xcode about your constant let isWinner != 10 it might be because the system doesn't know what value to assign isWinner. If it doesn't equal ten what does it equal? I looked over some documentation and I didn't see anything that indicated != could be used when declaring a variable.
I hope this is helpful.