Problem with .concat function

Problem with .concat function

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=[];

console.log(arr)  // [ 5, 6, 3, 2, 9 ]
console.log(age)  // []
// Only change code above this line

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:

Look at how .concat() works. How is the original array affected? What does it return?

1 Like

got it .thanks for the quick reply