Skip to content

Instantly share code, notes, and snippets.

@stepheneyer
Created May 1, 2015 15:52
Show Gist options
  • Save stepheneyer/43e8c1fdaaaa923c4976 to your computer and use it in GitHub Desktop.
Save stepheneyer/43e8c1fdaaaa923c4976 to your computer and use it in GitHub Desktop.
reverse a string using a for loop
function reverse(string) {
var rev = '';
for (var i = string.length - 1; i >= 0; i--)
rev += string[i];
return rev;
}
reverse("Hello");
//=> returns "olleH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment