DEV Community

Discussion on: Can you solve this interview problem?

Collapse
 
jayakrishnancn profile image
jayakrishnancn

Quick question, why did you use sort(() => 0 - Math.random()) ?
to reverse sort?

Collapse
 
sarathm09 profile image
sarathm09

No, it shuffles the array elements. Basically he is shuffling the array again and again till he gets it right