Answers for "javascript randomnumber"

4

javascript randint

/* If 1 argument is given, minimum will be set to 0 and maximum to this argument
 * If 2 arguments were given, the fist would be the minimum and the second the maximum
 * The function will return an integer in [min, max[
 */
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);
}
Posted by: Guest on February-11-2020
0

random number javascript

// The below code executes 0-100, I have used es6 arrow function concept
setInterval(() => console.log(Math.floor(Math.random()*101)),1000);
Posted by: Guest on August-10-2021

Code answers related to "javascript randomnumber"

Code answers related to "Javascript"

Browse Popular Code Answers by Language