Can't seem to find an answer to this, say I have this:
setInterval(function() {
m = Math.floor(Math.random()*7);
$('.foo:nth-of-type('+m+')').fadeIn(300);
}, 300);
How do I make it so that random number doesn't repeat itself. For example if the random number is 2, I don't want 2 to come out again.
You seem to want a non-repeating random number from 0 to 6, so similar to tskuzzy's answer:
It will return the numbers 0 to 6 in random order. When each has been drawn once, it will start again.
Generally my approach is to make an array containing all of the possible values and to:
The resulting set of numbers will contain all of your indices without repetition.
Even better, maybe something like this:
Then just go through the items because shuffle will have randomized them and pop them off one at a time.