I have an Array which I am randomizing:
var imgArray = [1, 2, 3, 4, 5],
i = imgArray[Math.floor(Math.random()*imgArray.length)];
However, due to the fact there are only 5 numbers, I'm getting a lot of duplicates.
For example: my outputs are often similar to 1, 4, 5, 5, 5, 3, 2, 2... And so on...
How can I prevent the "random" number from being the same as the previous number?
Any help is massively appreciated, thanks!!