Last Updated: February 25, 2016
·
1.32K
· creartinc

JavaScript's Modulo

Introduction

Hey what's up people since I signed up here, I would like to share this kinda tip about a mathematic this called "modulo". Which is the remainder of division using the % symbol, known as the modulus operator.

Example

And it could be used in the following function for example:

Use the

var isOdd = function (n) { if (n % 2 === 0) { return false; } else { return true; } };.

2 Responses
Add your response

var isOdd = function (n) { return !!(n % 2); };

I think it's easier :)

over 1 year ago ·

@avenger7x just saying ;)

over 1 year ago ·