I've been trying to do this for a long time but have every time failed. I have var rand = Math.floor(Math.random() * 5);
and log.push(rand);
. And to make sure that it doesn't repeat any values, I try:
function dontRepeat() {
var g = 0;
for (var i = 0; i < log.length; i++) {
if (log[log.length - i] == rand) g++;
if (g > 1) {
rand = Math.floor(Math.random() * n);
dontRepeat();
}
}
}
Please help me find out what is wrong.