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 trialRico Petrini
431 Pointsplease help me yes u Jason I need some hints please help thx for ur time
thx for ur time if u are reading this I get stuck a alot
// 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 = 15 % 5
// Task 2 - Enter your code below
let isPerfectMultiple = 3 > 0
1 Answer
Xavier D
Courses Plus Student 5,840 PointsHi Rico!
From what I see, you declared three constants, which are result, isPerfectMultiple, isGreater
Now, everything to the left of your equal signs are correct, but it seems that everything to the right of your equal signs needs some work. You didn't post the instructions for this challenge so getting help may be difficult since there's nothing indicating what the Code Challenge wants from you.
Fortunately, I remembered this challenge and noted the instructions, so I will place them here(let hope that the instructions haven't been updated from the last time I took this challenge):
//Challenge Task 1 of 2
//
//In the editor below, you have two constants - value and divisor. Step 1: Using the remainder operator, compute the remainder given the value and a divisor. Assign this value to a constant named result.
//
//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.
//
//Note: Only submit your answer after you've completed both steps 1 and 2
Rico, before I continue, I just want to give the advice of copying all Code Challenge instructions into the playground page of where you are writing your code, and once copied, highlight the instruction by pressing Command + A. Once highlighted, press Command + / to comment out the instructions That way, you don't have to bounce back and forth between Xcode and the Treehouse video on your Mac. I also like to use a new playground page for each challenge in order to better organize my notes.
Anywho, now that we got the instructions there, let see what it says (Again, hopefully Treehouse didn't update them from the last time I took it...)...
Step 1: Using the remainder operator, compute the remainder given the value and a divisor. Assign this value to a constant named result.
Step one states for you to compare and use the modulo, and you did that correct but then the instructions later stated to compare using the given value and divisor. The 'value' and 'divisor' has already been provided to you in the code challenge, which are:
let value = 200
let divisor = 5
Now you did use a value (i.e. 15) and a divisor (i.e. 5) in your work, but not the given ones from the code challenge. Just replace your 15 with the given value as well as replace your 5 with the given divisor. If you fix that then that would greatly improve your answer! Don't compare the actual number contained within the provided constants, compare the actual constants agains't each other (e.g. if the constant is declared as let value = 200, you will use 'value' to compare, not the 200 number).
The same thing goes for step 2, Once you compare the given value and divisor and store that data inside your result constant, you then need to compare your result constant against the number 0 and stored that data in the is perfect multiple constant (P.S. You need to use the double equal (i.e. ==) when comparing your result constant against 0...and being that you also have to assign this comparison to another constant, that would be total of 3 equal signs used for that one line of code). Remember, assigning data to a constant requires one equal sign, but comparing two expressions requires two equal signs. After that will be step three...
//Challenge Task 2 of 2
//
//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.
Here again, you did great with your code that is to the left of the assignment operator (i.e. =), but then you seem to have put some string interpolation to the right side of the equal sign. Step3 is just like step one and two, you basically have to do work with 2 items, and assign that result to a constant called isGreater. When comparing, you have use the Greater Than Equal Sign operator (i.e. >=), it kind of looks like a sad face if you tilt your head to the right. Lastly, when comparing, you have to compare the following....
let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5
Remember, compare the two constants and not the actual numbers within the constant and you should be able to pass the code challenge. Hope this helps.
Good Luck!