js random number 0 1 code example
Example 1: javascript random number between 0 and 10
Math.floor(Math.random() * 10);
Example 2: javascript randint
const Math.randint = function (min,max) {
[min,max] = (max===undefined)?[0,min]:(min>max)[max,min]:[min,max];
return Math.floor(Math.random*(max-min)+min);
}
Example 3: randint js
const Math.randint => (min,max) {
[min,max] = (max===undefined)?[0,min]:(min>max)[max,min]:[min,max];
return Math.floor(Math.random*(max-min)+min);
}
Example 4: javascript random number 1 or -1
var number = ((Math.floor(Math.random() * 2) - 2) * 2) + 1