My code return a Sorted Array

Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

We are trying to cut back on the number of spoiler solutions and would prefer users to not post solutions without discussion.

Thank you.

1 Like

Mine worked too…

var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
// Only change code below this line
var newArray = […arr];
return newArray.sort(function(a, b) {
return a === b ? 0 : a < b ? -1 : 1;
});

// Only change code above this line
}
nonMutatingSort(globalArray);

1 Like

Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thank you.

2 Likes