Looking to retrieve a random number from an array of numbers known as cardNumbertemp.
function shuffleCard(){
randomized = Math.floor(Math.random()*cardNumbertemp.length);
for (var i = 0; i < cardNumbertemp.length; i++){
if (randomized === cardNumbertemp[i]){
cardNumbertemp.splice(i, 1);
return randomized;
}
}
}
This function is designed to provide a single random number from the array (cardNumbertemp) and then remove it from the array. While it generally works well, occasionally it returns undefined values.