How to seek more reference for Return a Sorted Array Without Changing the Original Array

Tell us what’s happening:
Hi, I find it a bit challening to grasp the concepts in the functional programming section, and have referred to the hints quite extensively.

I feel that it might help to understand different, alternative ways to solve the challenges. Does anyone know if there’s such a page/platform to compare workable codes beyond those in the hint section?


Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:

1 Like

If you want to not manipulate the original array you can work with the spread operator to move all the items from the original array to the new one and start working just with the new one

I hope you understand my approach, feel free to ask any question you want

Just make a copy of original array. You have some options.
You can copy with rest operator


or with