Created
July 11, 2019 04:02
-
-
Save numb86/d8e0aa01d751e0dcb5a116a5f4748dd9 to your computer and use it in GitHub Desktop.
reverse の実装
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 = [1, 2, 3, 4, 5]; | |
for (let i = 0; i < arr.length / 2; i++) { | |
const front = arr[i]; | |
const back = arr[arr.length - 1 - i]; | |
arr[i] = back; | |
arr[arr.length - 1 - i] = front; | |
} | |
console.log(arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment