Created
December 5, 2018 15:38
-
-
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)
This file contains 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
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