0
Hours
0
Minutes
0
Seconds

Can you shuffle an array? | JavaScript Interview Question

@Yomesh Gupta
672

Given an array, write a function that should modify the array inline to generate a randomly picked permutation of the original array.

const arr = [1,2,3,4];

shuffle(arr);
console.print(arr);
// [4,2,3,1]

shuffle(arr);
console.print(arr);
// [2,3,1,4]

Loading IDE...