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 trialRob Brewer
1,202 Pointsthis challenge is so tough and doesnt make much sense
none of these questions were discussed in the previous video and the questions arent framed in a way that's easy to understand
1 Answer
Jonathan Ruiz
2,998 PointsFor the first question step one they want you to divide the value and divisor. Lots of code challenges will use the names we give data. Usually they ask you what they want and then tell you to assign that to something. In this case we are getting the remainder of constants value and divisor using the (remainder operator : % ).
let value = 200
let divisor = 5
let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5
let result = (value) / (divisor)
print(result)
In the question they want you to get the answer and assign it to a constant named result. Sometimes you can write code that executes correctly but check the name of the constant or variable to be sure it matches what the code challenge wants.
Question 1 step 2. This one is a bit more direct and it offers a great piece of knowledge. If you ever need to check for two numbers being perfectly dividable (ex. 25 / 5 ) just use the equality operator(ex. == ). In this question they ask you to compare the equality of result the new constant we made and 0. Then assign this to a new constant isPerfectMultiple.
let isPerfectMultiple = result == 0
Question 2 wants to check if someOperation is greater than or equal to anotherOperation. These questions make sure you know the different operators. Lastly you just need to create a new constant called isGreater and check if someOperation is greater than or equal to anotherOperation.
let isGreater = someOperation >= anotherOperation
This would be the whole thing, Hope I was helpful.
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)
print(result)
let isPerfectMultiple = result == 0
let isGreater = someOperation >= anotherOperation