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

Dean Kreseski
Dean Kreseski
2,418 Points

Really confused on the wording of this question and to what comparison operator I should use.

Not sure if its Line 1 or Line 2.

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

let isPerfectMultiple == 0

4 Answers

Dave Harker
PLUS
Dave Harker
Courses Plus Student 15,510 Points

Hi Dean Kreseski ,

You're really close, just the wording is a bit confusing perhaps in Step 2.

Step 2: When value obtained using a remainder operator is 0, this means that the value is a perfect multiple of the divisor. Compare the value of result to 0 using the equality operator and assign the resulting value to a constant named isPerfectMultiple.

They want you to assign the result of the comparison to the constant isPerfectMultiple e.g.

let word1 = "this"
let word2 = "that"

let isTheSameWord = (word1 == word2)

Nice work though, keep it up. :dizzy:
Dave

Dave Harker
Dave Harker
Courses Plus Student 15,510 Points

Oh, I just noticed in your step 1 you actually retyped the values assigned to the first two constants rather than using the constants in your equation... that should really be

let result = value % divisor

Ok, best of luck :smiley:
Dave

Dean Kreseski
Dean Kreseski
2,418 Points

thanks man and thank you for your kind words

Dean Kreseski
Dean Kreseski
2,418 Points

// 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 = value % divisor

// Task 2 - Enter your code below let isPerfectMultiple = (value == divisor)

this is what I have and its still giving me an error? Not sure what im doing wrong.

Dave Harker
Dave Harker
Courses Plus Student 15,510 Points

Hi again,

You're not comparing value to divisor at this step, you're comparing result to 0

If you really want, I can just give you the solution but I think you'll learn and enjoy it more if you get it yourself ... and I'm sure you can, you're very close now just need to re-read that step 2 and see what should be compared. I've noted it specifically above also (same as the step2, but written plainly) :smile:

Best of luck ... let me know if you just want the code line.

Dave.

Dave Harker
Dave Harker
Courses Plus Student 15,510 Points

oh, you'll also need to drop the code lines below those comment lines or they will just be seen as part of the comment

Good luck,
Dave

Dean Kreseski
Dean Kreseski
2,418 Points

I got it finally man the wording was throwing me off. But thank you again for the help.