Describe your issue in detail here.
I am not mutating global variable but still why this code is failing?
Your code so far
const globalArray = [1, 30, 4, 21, 100000];
function nonMutatingSort(arr) {
// Only change code below this line
let newArr=[...arr];
return newArr.sort((a,b)=>{
return a-b
})
// Only change code above this line
}
console.log(nonMutatingSort(globalArray));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Challenge Information:
Functional Programming - Return a Sorted Array Without Changing the Original Array