Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

modulo operator in javascript

// % in JS is the remainder, not modulo
//here is Shanimal's function for modulo operation
// n = your number, m = number to mod by
var mod = function (n, m) {
    var remain = n % m;
    return Math.floor(remain >= 0 ? remain : remain + m);
};
mod(5,22)   // 5
mod(25,22)  // 3
mod(-1,22)  // 21
mod(-2,22)  // 20
mod(0,22)   // 0
mod(-1,22)  // 21
mod(-21,22) // 1
Comment

PREVIOUS NEXT
Code Example
Javascript :: enzyme-adapter-react-17 
Javascript :: get ip address javascript 
Javascript :: math random js 
Javascript :: recursion in javascript 
Javascript :: generate apk debug react native 
Javascript :: timeout 
Javascript :: mongo mongoose join aggregation lookup 
Javascript :: jquery datatime 
Javascript :: message delete discord.js 
Javascript :: jquery before submit 
Javascript :: javascript switch assignment 
Javascript :: swap function javascript 
Javascript :: string to regex javascript 
Javascript :: node js connect to mongodb using mongoose 
Javascript :: strpos in javascript 
Javascript :: discord.js lockdown command 
Javascript :: import react 
Javascript :: a.reduce 
Javascript :: antd react native 
Javascript :: merge sort javascript 
Javascript :: Addition aruments in javascript 
Javascript :: remove table line button html using javascript 
Javascript :: js refresh 
Javascript :: jest listen EADDRINUSE: address already in use :::5000 jest 
Javascript :: array.reverse 
Javascript :: using bootstrap with react 
Javascript :: i want to redirect to main page from iframe javascript 
Javascript :: how to create a cookie in javascript 
Javascript :: how to filter an array by list of objects in javascript 
Javascript :: return promise in node js 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =