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 trialWillie Soedewa
3,299 PointsSwift Basic 2.0 Comparison Operator Quiz
I'm having difficulty with this current quiz i'm in. Mainly for the second challenge task which is:
"Great job with the first task! In this task, we have two math operations. Without computing the values of those operations, we'd like to know if the first operation, someOperation is greater than, equal to or less than anotherOperation.
Use the greater than or equal to operator and assign the Boolean result of the comparison to a constant named isGreater."
Can anyone help me where I'm making the mistake? I must not understand the question.
// 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
let isPerfectMultiple = result == 0
// Task 2 - Enter your code below
someOperation > anotherOperation
someOperation < anotherOperation
someOperation = anotherOperation
let isGreater = someOperation < anotherOperation; false
3 Answers
Anjali Pasupathy
28,883 PointsThis question is similar to part 2 of the first task.
The first task asked you to see if result == 0 and assign the corresponding Bool to the constant isPerfectMultiple. You performed this task by writing the following code:
let isPerfectMultiple = result == 0
This task is asking you to see if someOperation > anotherOperation and assign the corresponding Bool to the constant named isGreater. The code defining isGreater should mirror the code for isPerfectMultiple in structure.
I hope this helps!
Michael Friedman
495 PointsThis is still unclear to me.
Anjali Pasupathy
28,883 PointsIt's alright. I'll try to be more clear.
For task 2, you're suppose to create a constant called isGreater. This constant should be true if someOperation > anotherOperation, and false otherwise.
The expression "someOperation > anotherOperation" evaluates to true if someOperation is greater than anotherOperation, and evaluates to false otherwise.
Thus, you need to assign the constant "isGreater" to the expression "someOperation > anotherOperation":
let isGreater = someOperation > anotherOperation
I hope this helps!
Michael Friedman
495 PointsOh thanks, I got it sorted out on another thread!
Anjali Pasupathy
28,883 PointsYou're welcome! I'm glad you figured it out! (:
Willie Soedewa
3,299 PointsWillie Soedewa
3,299 PointsHi Anjali,
Thanks for helping out! I've got it figured out haha!
Anjali Pasupathy
28,883 PointsAnjali Pasupathy
28,883 PointsYou're welcome! (:
Michael Friedman
495 PointsMichael Friedman
495 PointsI'm afraid this wasn't enough of a hint for me. Would you be willing to be more forthcoming with some information?