Functional Programming - Return a Sorted Array Without Changing the Original Array

Tell us what’s happening:
Describe your issue in detail here.
There seems to be a bug on the tests performed on this challenge. tests below keep failing regardless to whether I create a copy of the received array with the spread operator, slice or concat methods.

  1. The globalArray variable should not change. —tests with log comaring both arrays indicate that the globalArray has not been mutated.

  2. nonMutatingSort(globalArray) should return [2, 3, 5, 6, 9] — This can only pass if the innitiation array is chnaged to the array provided in the test.

    Your code so far

const globalArray = [1, 30, 4, 21, 100000];

function nonMutatingSort(arr) {
// Only change code below this line
return [].concat(arr).sort(function(a, b) {
  return a - b;
});
// Only change code above this line
}

nonMutatingSort(globalArray);

console.log("global",globalArray,"new",nonMutatingSort(globalArray))
  **Your browser information:**

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

Challenge: Functional Programming - Return a Sorted Array Without Changing the Original Array

Link to the challenge:

You changed globalArray, it should be what was in the starting code.

Got it, resetting the Editor did the needful. Thanks!