Active learning: sizing a canvas box

I have not been able to solve the following question from the basic math in JS lesson.

“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.”

I have tried to solve every other part of this section but I cannot figure out how to use the Modulo operator to get a remainder of 250. I think I am stuck on the basic math?

Hi @Tess_Bishop, welcome to the community!

This is a bit of a funny question, and something you’d rarely do in real code; yes, it is basically here to test your comprehension of the basic math.

So, modulo returns the remainder you’ve got left after you’ve taken as many whole amounts of the second number out of the first number as you can.

So for example 50 % 15 returns 5, because the whole of 15 goes into 50 3 times, then you’ve got 5 left over.

So given this, what can you change 50 and 15 to, to get it to return 250?

1 Like

Thank you @chrisdavidmills ! I figured it was something random but I wanted to get it right! haha. Thank you so much for your response. I’ve really been enjoying the lessons!

Because I’m slightly mathematically challenged, after some googling I figured out the answer: 1250 % 1000. This math section has been challenging for me! I appreciate this groups support while I am struggling to learn the basics at this point.

@Tess_Bishop you are welcome — feel free to ask any questions that come to mind.

Also bear in mind that there are many different answers to this question. it could be:

  • 1250 % 500
  • 550 % 300
  • etc.
1 Like