File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
1-js/05-data-types/05-array-methods/5-copy-sort-array Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 1- We can use ` slice() ` to make a copy and run the sort on it :
1+ Podemos usar ` slice() ` para fazer a cópia e executar o método ` sort() ` logo depois :
22
33``` js run
44function copySorted (arr ) {
Original file line number Diff line number Diff line change @@ -2,17 +2,17 @@ importance: 5
22
33---
44
5- # Copy and sort array
5+ # Copie e ordene o array
66
7- We have an array of strings ` arr ` . We'd like to have a sorted copy of it, but keep ` arr ` unmodified .
7+ Temos um array de strings ` arr ` . Gostaríamos de ter uma copia ordenada desse array, porém mantenha ` arr ` do mesmo jeito, sem modificações .
88
9- Create a function ` copySorted(arr) ` that returns such a copy .
9+ Crie uma função ` copySorted(arr) ` que retorna a copia .
1010
1111``` js
1212let arr = [" HTML" , " JavaScript" , " CSS" ];
1313
1414let sorted = copySorted (arr);
1515
1616alert ( sorted ); // CSS, HTML, JavaScript
17- alert ( arr ); // HTML, JavaScript, CSS (no changes )
17+ alert ( arr ); // HTML, JavaScript, CSS (arr sem alterções )
1818```
You can’t perform that action at this time.
0 commit comments