Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
What does % stand for in javascript?
example:
if (score % 5 == 0)
{
numObsticles += 5;
};
Thank you Empire!
leanna.. no... i'm not stupid..
5 Answers
- Empire539Lv 78 years agoFavorite Answer
Modulo. Basically, it returns the remainder in a division operation.
Example:
22 / 5 = 4, remainder 2. Thus, 22 % 5 = 2
22 / 7 = 3, remainder 1. Thus, 22 % 7 = 1
- 8 years ago
% is called a modulo or modulus. It essentially the remainder sign, so your code is saying, if "score" divided by 5 has a remainder of 0, do whatever.
example:
5 % 3 = 2
10 % 5 = 0
169 % 12 = 1
etc.
In other words, it tells you whether your given number is evenly divisible by your second number.
Source(s): personal experience with coding in Javascript - green meklarLv 78 years ago
It's the modulo operator. See here:
http://en.wikipedia.org/wiki/Modulo_operation
However, it can also be used in alternative ways of expressing characters in the code. So you have to be careful when you read it.