Learning basic JavaScript Lessons: Questions about modulo


So if % divides the first number by the second.. and 23%10 = 2.3 and then evaluates to 3..does that mean its rounded up. I don't understand why its 3. And how is 14/3 evaluated to 2 on my computer. doing the calculations myself 14/3 = 4.6666667

Just wanting to fully understand it, if anyone can clarify.


if you do 14/6 those two numbers are int hence you have the final answer will automatically be int. int(Integer) are whole numbers which mean they are not decimals(i.e. 45 -> integer but 45.3 -> not Integer)
The modulo operator operates on the bases of how many of this can i get in the other what is the remainder

e.g 33 %12 is basically the same as saying how may whole 12's can I find in 33 , what would be the reminder
Therefore 33%12  --> 2( ie 24 of the 33) remainder 9(we are left with 9 of the 33)
Since the modulo operator is only interested in the remainder the answer will be 9

Now using the analogy you provided

23 % 10 again is saying how many whole 10's can i get in 23 and what would be the remainder after that
Therefore 23 %10  --> 2(i.e. 20 of the 23) remainder 3(we are left with 3 of the 23)
Hence the answer will be the remainder which is 3

Hope this helped clarify the modulo operator for you

Stuck on question 9 modulo operator

Is this question really about java or javaScript? Because JS would not treat 14/6 as integer division (java would).


nobody makes sense to me!! :confused: :hankey:


:cry: why me?! :cry:


23 % 10 = 3 because % looks at the remainder when dividing.

Like, 13 divided by 3 is something like 4._____ right? But we know that 3 goes into 13 4 times, and there is a remainder of 1.

So, 13 % 3 = 1, and 23 % 10 = 3.


Do you have a problem or a question? Then maybe post it in your own thread.


Sorry for lack of response right after I posted this I got sick so haven't been around my computer. I did in fact mess up and confuse java as being the same as JavaScript only after it was pointed out that I realize they are different. So yes I meant JavaScript. So another question I have is, maybe cause I'm still in the basics of learning JavaScript but how do you make plugins with JavaScript for a game like rpg maker? Maybe I fail to see how currently because all my lessons thus far seem to do with math alone.


If you're asking if these JavaScript lessons soon get with math, I would say, sort of. You will soon learn about Math.floor and Math.random, but you won't use them much.

If you want to test out stuff, like not in Codecademy but like just try things out, search Codecademy Labs.


I think that I have the solution. I forgot to put the semicolon on the end like this ;
Now it works.