Created
October 26, 2014 07:49
-
-
Save macikokoro/4e2337bad6ac0788ff1a to your computer and use it in GitHub Desktop.
Reversing a string without using reverse( ).
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
var string = "Batman"; | |
var reverse = function (string) { | |
var newString = ""; | |
for (var i = string.length; i >= 0; i--) { | |
newString += string.charAt(i); | |
} | |
return newString; | |
}; | |
console.log(reverse(string)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment