Last active
March 22, 2020 09:25
-
-
Save francoisgeorgy/c4f7ef58d71d87d95158d0aaf50e998e to your computer and use it in GitHub Desktop.
reverse #array in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let a = ["zero", "one", "two", "three"]; | |
| a.slice(0).reverse().map((o, i) => { | |
| console.log(`${i}, ${o}`); | |
| }); | |
| /* RESULT: | |
| > let a = ["zero", "one", "two", "three"]; | |
| > a.slice(0).reverse().map((o, i) => { console.log(`${i}, ${o}`); }); | |
| 0, three | |
| 1, two | |
| 2, one | |
| 3, zero | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment