Q:

Write a JavaScript program to get a random integer in the specified range

0

Write a JavaScript program to get a random integer in the specified range.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
console.log(randomIntegerInRange(0, 5));
console.log(randomIntegerInRange(2, 5));
console.log(randomIntegerInRange(5, -5));
console.log(randomIntegerInRange(-2, -7));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now