Created
October 23, 2012 19:35
-
-
Save jakeboxer/3941060 to your computer and use it in GitHub Desktop.
Naive string reverse implementation
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 reverseString(oldString) { | |
var newString = ""; | |
for (var i = oldString.length - 1; i >= 0; i--) { | |
// This line does exactly the same thing as: newString = newString + oldString[i]; | |
newString += oldString[i]; | |
} | |
return newString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment