Home generating a random number without repetitions
Reply: 0

generating a random number without repetitions

user475 Published in May 21, 2018, 3:01 am

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;
    randNum = Math.floor(Math.random() * quotes.length);
  } while(prevnumb == randNum);
  prevnumb = randNum;
  return randNum;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.400227 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO