iOS Swift Basics Swift Operators Working With Operators: Part 2

Rabbie Wordie
Rabbie Wordie
1,339 Points

Assignment is unclear on how to correctly proceed. Please help.

Im totally lost on what to do next. This code is not working. I do not know if I have been taught the code I need to complete this challenge.

operators.swift
// Enter your code below

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

1 Answer

Hi Rabbie,

I see the you did the first stage of the challenge ok - the wording of the second challenge is: "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)".

So we need to declare a Boolean constant that contains the result of initialScore != 10 - in your code you've written that statement, not assigned it to a constant and then declared isWinner as a duplicate of initialScore which would make isWinner an integer of 9 instead of a false Bool.

Code below, hope this helps:

var initialScore = 8
initialScore += 1

let isWinner = initialScore != 10
Rabbie Wordie
Rabbie Wordie
1,339 Points

I literally solved it like a second before I got this reply. BUT THANK YOU!