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!
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 trial
I am unsure of how to write out the result, and how to write the code to get a remainder.
Could someone help me figure out how to write the remainder code to get the result? Also for step 2 i know that I am supposed to use == but not sure how to format it.
// 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 = "The % of \(value) and \(divisor) // Task 2 - Enter your code below let isPerfectMultiple = "0 == \(result)"
The challenge doesn't want you to specify any text. It wants the calculation using the variables provided. The first step uses the modulo operator:
let result = value % divisor
This is the remainder for value divided by divisor. The second step wants a boolean value that determines if the result is a perfect multiple. For this to be true result would equal zero
let isPerfectMultiple = result == 0