Introduction to JavaScript

Math Operators II

Now let's generate a space fact while we learn a brand new operator called – drum roll please – the modulus.

The idea behind the modulus is to show you the remainder after you divide a number.

So, if you divide 13 / 5, 5 goes into 13 two times, and there will be 3 remaining. A modulus, denoted by a %, would take 13 % 5 and return the remainder 3.

How on Earth is this useful?

Let's ask a question a modulus can solve: What will the moon phase be one year from today?

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.