In this post, we will randomly shuffle array.
let arr = [‘1′,’2′,’3’]; function shuffleArr(array){ let randomNum, randomIndex; let newArrary = []; while(arr.length > 0){ randomNum = Math.floor(Math.random()*array.length); randomIndex = array[randomNum]; newArrary.push(randomIndex); array.splice(randomNum,1) } return newArrary; } shuffleArr(arr);