Tell us what’s happening:
refer the code. the value of age is updating(concatinating) .why?
Your code so far
var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
// Only change code below this line
let age=[];
age.concat(arr);
console.log(arr) // [ 5, 6, 3, 2, 9 ]
console.log(age) // []
// Only change code above this line
}
nonMutatingSort(globalArray);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
.
Challenge: Return a Sorted Array Without Changing the Original Array
Link to the challenge: