0
0
MSMaqsud Safin
The code arr is an array of integers, and function printNum() is defined to print out the contents of arr. Every time the function is called, arr is copied to num and a random number is generated. The while loop checks to see if arr includes the number being printed, and if not, arr is incremented by 1 and the number is printed again. The for loop prints out the contents of arr at intervals of 1000.
const arr = []
function printNum(num) {
while (arr.length !== num) {
randm = Math.floor(Math.random() * (num+1))
if (!arr.includes(randm)) {
arr.push(randm)
return
}
}
}
number=100
setInterval(printNum(number), 1000)
for (let i = 0; i < arr.length; i++) {
console.log(arr[i]);
setInterval(printNum(number), 1000)
}