Possible instruction error in Basic math in JavaScript Guide? #703
-
Hi, I'm quite new at this and currently completing TOP so I apologize for my ignorance or perhaps boldness (lol) but I came across an instruction in the Active learning: sizing a canvas box section that seems a bit mathematically weird for me. Link: Editable Canvas Example Exercise 3 says: "Change the line that calculates x so the box is 250px wide, but the 250 is calculated using two numbers and the remainder (modulo) operator."
How exactly is one supposed to calculate a total remainder of exactly 250px using % and only 2 numbers? Or was this instruction meant to say “division operator”? A division seems to make more sense, given that it's simple JS math. Once again, apologies if I'm overstepping (lol) but I wasn't able to let it go and the only simple solution I found was to state |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You can calculate |
Beta Was this translation helpful? Give feedback.
Sure. Your goal is to find
a
andb
such thata % b = 250
. In other words,a = b * c + 250
, whereb
is something larger than 250 (so it can allow a remainder of 250). Therefore one easy solution is to pickb = 251
andc = 1
, then you would havea = 251 + 250 = 501
. Verify:501 % 251 === 250
.