Skip to content

Instantly share code, notes, and snippets.

@iCaspar
Created December 5, 2018 15:38
Show Gist options
  • Save iCaspar/3788e67860b83d88c0877e2da67680fc to your computer and use it in GitHub Desktop.
Save iCaspar/3788e67860b83d88c0877e2da67680fc to your computer and use it in GitHub Desktop.
JS algorithm to reverse a string (without using conversion to array and back)
function strReverse(str) {
let reverse = ''
let i = str.length
while (i-- > 0) {
reverse += str[i]
}
return reverse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment