About Javascript - 10%3 remainder operator

Hi folks,

Thanks from the bottom of my heart to able join this service to learn to code.
However, I am just a beginner in learning Javascript.
I meet problem to have difficult to understand this simple function of " The remainder operator, sometimes called modulo , returns the number that remains after the right-hand number divides into the left-hand number as many times as it evenly can: 11 % 3 equals 2 because 3 fits into 11 three times, leaving 2 as the remainder."

p.s. English is not my first language.

I am wondering if someone can explain it to me! I had tried to run different numbers to figure out the explanation; however, I am still confusing of the remainder operator.

Thanks very much.

Break out a pad and pencil…

   ______
16 ) 255 | 1
   - 16
   ____
      9


   ______
16 ) 255 | 1    this will be the tens digit of the quotient
   - 16         this is 1 times 16; subtract from 25
   ____         bring down the 5 and divide again
      95 |  5   this will be the ones digit of the quotient
    - 80        this is 5 times 16; subtract from 95
    ____ 
      15        not divisible by 16, so the Remainder

Add the tens digit times 10 + the ones digit

 10 + 5  == 15

So, 255 / 16 equals 15 with 15 remainder.

255 % 16  ==  15
2 Likes