Home generating a random number without repetitions
 I am trying to generate a series of random numbers generating every time a different one, I came up with a simple function in javascript but it still gives me the same number consecutively 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; }