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 trialMatt Conway
1,572 PointsHow to pick the correct results?
With this task, not sure how to get a boolean to PICK which operation is the right one. I already knew the right one, based on Playground calculations, but not sure of the boolean formula to pick which one is the right one?
Challenge Task 2 of 2
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. /Users/mattconway/Desktop/Screen Shot 2016-01-08 at 3.12.24 PM.png
// Enter your code below
let value = 200
let divisor = 5
let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5
someOperation >= anotherOperation
someOperation == anotherOperation
someOperation <= anotherOperation
let isGreater = someOperation <= anotherOperation
// Task 1 - Enter your code below
let result = value % divisor
// Task 2 - Enter your code below
let isPerfectMultiple = result == 0
1 Answer
Marina Alenskaja
9,320 PointsHi Matt
Your mistake here is in the isGreater constant: you used less than or equal to instead of greater than or equal to:
let isGreater = someOperation >= anotherOperation
Oh and note: when checking greater that/less than or equal to - you only need to check twice, since both will be true if the numbers are equal. Which is why the boolean value is perfect - only true or false is possible :-) I hope that helps!