Generating 10 unique random numbers (0-99) should be an easy exercise.
1.- Please help me generate 10 random numbers and store them in an array without any repeats.
Despite my efforts, all the answers I find online are too complicated or lengthy.
In the code snippet provided below, I managed to generate the 10 numbers, but they keep repeating. Can someone offer a solution? (I tried using If/else statements, but it didn't work as expected) :(
numbers=[]
for(i=0;i<10;i++){
var oneRandomNum = Math.floor(Math.random()*100);
if(!numbers.includes(oneRandomNum)){
numbers.push(oneRandomNum);
}
}
console.log(numbers);
Thank you for your assistance!!!!! :)