JavaScript Code

JavaScript Modulus Operator


Arithmetic Modulus

% symbol is used for arithmetic modulus operator

arithmetic modulus operator takes two values/variables as operands and returns the remainder in the division of the left operand divided by the right operand

a % b  //remainder when a divided by b
6 % 4  //remainder when 6 divided by 4

Examples

1. remainder of the division a divided by b

var a = 6;
var b = 4;

var remainder = a / b;

console.log(remainder);