Implement a shuffle
function that takes an array as input and returns a new array with its elements shuffled in random order. The original array should remain unmodified.
Requirements:
shuffle
.Example Usage:
const arr = [1, 2, 3, 4, 5]; const shuffledArr = shuffle(arr); console.log(shuffledArr); // [3, 5, 1, 4, 2] (example, actual result will vary) console.log(arr); // [1, 2, 3, 4, 5] (original array remains unchanged)