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 trialMason Stevens
1,068 PointsSetting isWinner to a number between 0-9.
Right now I have set isWinner to be true but how do I make it so that isWinner is any number between 0-9 and if the number is 10 then it is false?
// Enter your code below
var initialScore = 8
initialScore += 1
let isWinner = true
isWinner <= 10
let notWinner = !isWinner
1 Answer
andren
28,558 PointsA big hint for this task is that you can directly assign the result of a comparison to a variable. Like this:
let example = 3 == 2 // equals operator
// example ends up storing the Boolean "false" since 3 is not equal to 2.
let example2 = 3 != 2 // not equals operator
// example2 ends up storing the Boolean "true" since 3 is not equal to 2.
So you don't have to set it to true or false manually, but instead a comparison that results in true or false. With that knowledge you should be able to figure out the answer to the challenge.