I\'ve been searching around for some answers to this issue, but nothing seems to work when I try to find a solution.
What I\'m trying to achieve is to make a spinner
This function will use Math.random() to randomly choose a number in an array, and not choosing it again until all numbers were used:
var originalArray = ['360', '330', '300', '270', '240', '210',
'180', '150', '120', '90', '60', '30'];
var totalSpin = [];
function spinArray(){
var spin = Math.floor(Math.random()*originalArray.length);
if(totalSpin.indexOf(spin) == -1){
totalSpin.push(spin);
parag.innerHTML = originalArray[spin];
} else {
spinArray();
}
if(totalSpin.length == originalArray.length)
totalSpin = [];
}
Here is the fiddle: https://jsfiddle.net/628yqz0v/4/