Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Return a sorted array without mutating the original array JS Javascript Free Code Camp FCC

var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
  // Add your code below this line
  return [].concat(arr).sort(function(a, b) {
    return a - b;
  });
  // Add your code above this line
}
nonMutatingSort(globalArray);
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Return #sorted #array #mutating #original #array #JS #Javascript #Free #Code #Camp #FCC
ADD COMMENT
Topic
Name
4+8 =