en.javascript.info/1-js/4-data-structures/8-array-methods/5-copy-sort-array/solution.md
2016-03-21 10:16:55 +03:00

248 B

We can use slice() to make a copy and run the sort on it:

function copySorted(arr) {
  return arr.slice().sort();
}

let arr = ["HTML", "JavaScript", "CSS"];

*!*
let sorted = copySorted(arr);
*/!*

alert( sorted );
alert( arr );