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

I don't understand how to write a comparison without "If" and "Then"

I don't understand how to write a comparison without "If" and "Then"

// Enter your code below

var initialScore = 8
initialScore += 1

let isWinner = !10

1 Answer

Gavin Butler
.a{fill-rule:evenodd;}techdegree seal-36
Gavin Butler
iOS Development with Swift Techdegree Graduate 15,489 Points

Hi Morgan - me again :). I can see what you're trying to do, and you're close but you need to compare initialScore to 10 (the question isn't too well worded as it refers to a 'total score'). So the comparison part looks like this: initialScore != 10. Now, to say let isWinner equal the result of comparing initialScore to 10 you write: let isWinner = initialScore != 10..... and then tell swift what you want isWinner to be once this comparison is made (true? false?) - if you look up the ternary conditional operator you should be able to complete the code. https://www.hackingwithswift.com/example-code/language/what-is-the-ternary-operator