-2

there,for last few days,i have started learning JavaScript while watching tutorial videos and **`

the mentor mention something that 100 % 3 answer would be 1 in the console

`** but what i could not get him what he did not describe properly i guess or may be i was to numb to understand.

Can anyone describe properly please whats the issue with 100 % 3 and the answer 1 comes out in the console,so that i could learn JavaScript effective way.

Thank you..

Mizan
  • 1
  • 2
  • 4
    Possible duplicate of [What does % do in JavaScript?](https://stackoverflow.com/questions/8900652/what-does-do-in-javascript) – Professor Allman Aug 15 '18 at 17:33
  • Possible duplicate of [How can I use modulo operator (%) in JavaScript?](https://stackoverflow.com/questions/16505559/how-can-i-use-modulo-operator-in-javascript) – Karan Bhagat Aug 15 '18 at 17:36

2 Answers2

0

If you divide 100 by 3, the answer is 33 with a remainder of 1. The % character gives you the remainder if you would divide the number on the left by the number on the right.

3 % 3 = 0
4 % 3 = 1
5 % 3 = 2
6 % 3 = 0
etc..
Evert
  • 75,014
  • 17
  • 95
  • 156
0

In JavaScript, % is a modulus operator. It returns a reminder after a complete integral division of the numerator by denominator.

So 100 % 3 = 1. 8 % 5 = 3. 14 % 6 = 2 and so on.

Harshal Patil
  • 11,402
  • 9
  • 38
  • 85