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 trialscott suegav
384 PointsI feel like I've done everything right, I'm not sure where to go from here
I'm stuck , please help
// 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
result == 0
let isPerfectMultiple = false
someOperation == anotherOperation
let isGreater = false
1 Answer
Ben Shockley
6,094 PointsOkay, so you've got a few things wrong here.
First in task one, it says to use the remainder operator to compute the remainder of the value and the divisor. You used the division operator. % is the remainder operator. so task one should look like this.
// Enter your code below
// Task 1 - Enter your code below
let result = value % divisor
Then, for task number two, you're supposed to compare what's in result
with 0 to see if they are equal. If so then you set the isPerfectMultiple
constant to true, otherwise, set it to false. So what you want to do in this situation where you comparing two things and deciding what to do afterwards is to use an if statement. You'll also need to go ahead and declare the isPerfectMultiple
constant, but not assign it anything yet, because you declare inside the if statement, it will only exist inside that if statement, and you won't be able to use it elsewhere. So the second step should look like this.
// Task 2 - Enter your code below
let isPerfectMultiple: Bool
if result == 0 {
isPerfectMultiple = true
} else {
isPerfectMultiple = false
}
Does all that make sense?