whats the error in my code?
// 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 = 5 / 200 = 0 // Task 2 - Enter your code below let isPerfectMultiple = "\(result) > 0"
J.D. Sandifer18,812 Points
I'm guessing you're on step one. Assuming that, here's what's up:
- You have an error in syntax - probably just a typo. The
=assignment operator is used for assigning values to variables or constants like this:
let aConstant = 1. You have it twice in one line which doesn't work because the second one creates this expression
200 / 5 = 0. You can't assign a value to a calculation. Start by removing the last two characters on that line and your code won't have any compilation errors. However...
- Your task is to assign the remainder of dividing
value(not 200) by
divisor(not 5). Using the variables or the values might not even matter, but you're supposed to get the remainder - not do division - and you have the order backward. Hint:
%is the operator you want for that first task.
- Finally, the second task is to assign a comparison - whether
resultis equal to 0 - to
isPerfectMultiple. The goal is not to create a string (what you're doing now), but to create a comparison that gives a true or false value. You'll want the
==equality comparison operator for that.