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 trialValeria Ruiz
948 Pointsoperands and if then situations
hi guys, thanks so much for coming to help,
the instructions say declare a constant isWinner as the comparison equation which checks if the answer is 10 or anything but 10. if it is anything but then the player wins, if it is 10 they loose.
I think I need an if then statement, which I don't know how to do on Swift, also, we strictly have to use the operand "!". So I really don't know how to do it.
Please help
// Enter your code below
var initialScore = 8
let totalScore = ++initialScore
initialScore != 10
let isWinner = initialScore
1 Answer
miikis
44,957 PointsHi Valeria,
You're kind of right; if the question was asking you to implement the whole game then you would definitely need if-then statements βΒ among other things β to be successful. As it stands, it's just asking you to load the constant isWinner with an expression that evaluates to true or false in accordance with the given parameters. It should look like this:
var initialScore = 8
let totalScore = ++initialScore
let isWinner = totalScore != 10
Valeria Ruiz
948 PointsValeria Ruiz
948 PointsThanks so much!! that helps out a lot!
Ryan Maneo
4,342 PointsRyan Maneo
4,342 PointsCould you please check out my question, Makis? https://teamtreehouse.com/community/hm-stuck-on-this-one