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

Maria Angelica Dadalt
Maria Angelica Dadalt
6,197 Points

Whats is the answer?

someOperation >= anotherOperation

let isGreater = someOperation > anotherOperation isGreater = false

operators.swift
// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below
let result = 200 % 5

// Task 2 - Enter your code below
result == 0
let isPerfectMultiple = true

let isGreater = someOperation > anotherOperation
isGreater = false

Hello Maria, the answer for Task 1 is:

let result = value % divisor

let isPerfectMultiple = result == 0

Why? The question wants us to store the remainder of 'value' over 'divisor'. Therefore, we must use the constants to find the result. Afterwards, we must assign the comparison value (boolean) of "result" and 0 to isPerfectMultiple. So, we use the equal to operator (==) to compare result and zero. They only want the value, regardless if it is false or true.

Task 2: let isGreater = someOperation>= anotherOperation

someOperation <= anotherOperation

Why? We want to give the boolean value of the 'someOperation' being greater than or equal to 'anotherOperation' to isGreater. Note, it also says to compare them with the less than or equal to operator (<=). We compare them, but without assigning it to anything. Hope this helped!

1 Answer

Hi Maria, The answer you looking for is:

// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below
// have to use the constant name. They hold the values
let result = value % divisor
// Then check to see if result equal to 0 and assign it to a constant "isPerfectMultiple"
//This is all in task one
let isPerfectMultiple = result == 0

// Task 2 - Enter your code below
// you need to use Greater than equal to >=. assign it to a constant "isGreater"
// This is all in task 2 
let isGreater = someOperation >= anotherOperation