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 trial

iOS Swift Basics Swift Operators Working With Operators: Part 2

Monzer Selim
PLUS
Monzer Selim
Courses Plus Student 3,849 Points

need help with the binary operator challenge here

in this game of ours, we have an odd scoring mechanism . At the end of the round, if your score is 10, you lose! If it's anything but 10, you win.

Declare a constant named isWinner and assign the results of a comparison operation to check whether the player has won or not. For example, if the total score is not 10, then the player has won and isWinner should equal true. (Hint: Use the NOT operator)

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1
initialScore != 10
let isWinner = initialScore

I has same exact problem, could not understand the question! Extremely frustrating!!!!!!

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there Monzer! You're really close here and you have the right idea, but there's a problem. You do the comparison to see if the initial score is not equal to 10. And it does the comparison, but it never puts the result of the comparison anywhere. It's sort of hanging out there in limbo. What we want to do is assign the results of the comparison (which will be a true or false) back into the isWinner constant. Take a look:

var initialScore = 8
initialScore += 1
let isWinner = initialScore != 10

This is essentially what you did except that in your code that comparison sort of doesn't go anywhere. And then you set isWinner to be the current value of initialScore which is now 9. But isWinner should contain a true or false.

Hope this clarifies things! :sparkles:

Why treehouse never has a Reveal Answer after you've gotten it wrong so many times is beyond me // PLEASE ADD THIS FEATURE