Tell us what’s happening:
I understand, that the challenge was created to use concat method, but would such solution with slice(0,) be correct outside of FCC?
Your code so far
var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
// Add your code below this line
const asc = (a,b)=>{a-b};
return arr.slice(0,).sort(asc);
// 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/67.0.3396.99 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