Skip to content

Instantly share code, notes, and snippets.

@oguzhancvdr
Created October 22, 2022 19:39
Show Gist options
  • Save oguzhancvdr/a44d84118de97aea9cb8c7572480d6a1 to your computer and use it in GitHub Desktop.
Save oguzhancvdr/a44d84118de97aea9cb8c7572480d6a1 to your computer and use it in GitHub Desktop.
// for lightweight strings this is well-enough
const reverse = str => str.split('').reverse().join('');
// more performant way for not lightweight strings :)
const reverseString = (string) => {
let reversedString = "";
for (let i = string.length - 1; i >= 0; i--)
reversedString += string[i];
return reversedString;
}
@oguzhancvdr
Copy link
Author

Reverse the String

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment