Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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