iOS Swift Basics Swift Operators Working With Operators: Part 2

Morgan Norelius
Morgan Norelius
682 Points

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"

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1

let isWinner = !10

1 Answer

Gavin Butler
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