Modulo operator in JS

Hello, I was finishing the quiz on Variables/Javascript Programming and there was the last question which I had problem of understanding ( not solving since i can use console to do the math - simple instructions in console when opened is (10+22)%3 = 2; ). Problem that I have is solving the math how that becomes 2. The book only shows an example as 314%100=14 and another one 144 % 12 = 0 .
I just can’t get my head around this math…
"There is one more arithmetic operator, which you might not immediately
recognize. The % symbol is used to represent the remainder operation. X % Y
is the remainder of dividing X by Y. For example, 314 % 100 produces 14, and
144 % 12 gives 0. The remainder operator’s precedence is the same as that of
multiplication and division. You’ll also often see this operator referred to as
modulo."
Could anyone explain this math as a procedure as in how is the answer to last quiz question 2 ?

Thanks in advance,
Kristian

Hi @KristianR i think this video can help you to better understand modulo operator.

2 Likes

Ah so remainder function divides numbers as much as it can and the leftover of complete number that is divided is the remainder. :smiley:
Thanks this was much helpful :smiley:

1 Like

I always glad to help if i can!

2 Likes