Skip to content

Instantly share code, notes, and snippets.

@NeniEmSu
Last active January 5, 2023 16:40
Show Gist options
  • Save NeniEmSu/3be36122dbfa97d36a2b04c402539531 to your computer and use it in GitHub Desktop.
Save NeniEmSu/3be36122dbfa97d36a2b04c402539531 to your computer and use it in GitHub Desktop.
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