Q:

Write a JavaScript program to get an array of given n random integers in the specified range

0

Write a JavaScript program to get an array of given n random integers in the specified range. 

All Answers

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

const random_intArray_In_Range = (min, max, n = 1) =>
  Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);
console.log(random_intArray_In_Range(1, 20, 10));
console.log(random_intArray_In_Range(-10, 10, 5));

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