I am trying to generate a series of random numbers without repeating the same number twice, I came up with a simple function in javascript but it doesn't work, and I fail to understand why, can anyone help me please
function random(){
var randNum;
var prevnumb;
do{
randNum = Math.floor(Math.random() * quotes.length);
} while(prevnumb == randNum);
prevnumb = randNum;
return randNum;
}
Aucun commentaire:
Enregistrer un commentaire