hwo to randomize an array code example
Example 1: how to randomize an array
const getShuffledArr = arr => {
const newArr = arr.slice()
for (let i = newArr.length - 1; i > 0; i--) {
const rand = Math.floor(Math.random() * (i + 1));
[newArr[i], newArr[rand]] = [newArr[rand], newArr[i]];
}
return newArr
};
Example 2: how to randomise array javascript
- @bookingcom/ext-promotions-pricing-hub-list@2.27.0