Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Created October 26, 2014 07:49
Show Gist options
  • Save macikokoro/4e2337bad6ac0788ff1a to your computer and use it in GitHub Desktop.
Save macikokoro/4e2337bad6ac0788ff1a to your computer and use it in GitHub Desktop.
Reversing a string without using reverse( ).
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