Return a Sorted Array Without Changing the Original Array Doubt

Tell us what’s happening:
What is wrong here?

Your code so far


var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
  // Add your code below this line
  var a = [];
  a.concat(arr);
  return a.sort(function(a,b){
    return a - b;  
  });
  // Add your code above this line
}
nonMutatingSort(globalArray);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/return-a-sorted-array-without-changing-the-original-array

a.concat(arr) returns a new array. It does not change a

The Array.prototype.concat() method does not change any existing array, it only returns an array of merged arrays. So you need to store a.concat(arr) somewhere so you can use it, probably the variable a.