Last active
January 5, 2023 16:40
-
-
Save NeniEmSu/3be36122dbfa97d36a2b04c402539531 to your computer and use it in GitHub Desktop.
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 testString = 'hello'; | |
const reverse = (s) => { | |
let arr = Array.from(s), | |
left = 0, | |
right = arr.length - 1; | |
while (left < right) { | |
[arr[left], arr[right]] = [arr[right], arr[left]] | |
left++ | |
right-- | |
} | |
return arr.join('') | |
}; | |
reverse(testString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment