Created
March 26, 2020 11:21
-
-
Save ilanl/f4023d71db2640076d85c3df6282f719 to your computer and use it in GitHub Desktop.
array up and down
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
const arr = [ ...Array(100).keys() ].map( i => i+1).sort((a, b) => a-b); | |
console.log(...arr) | |
var results = [] | |
while (arr.length > 0) { | |
results.push(arr.shift()) | |
results.push(arr.pop()) | |
} | |
console.log(...results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment