Skip to content

Instantly share code, notes, and snippets.

@krrishd
Created June 20, 2014 00:29
Show Gist options
  • Save krrishd/f75fc21c27811085543b to your computer and use it in GitHub Desktop.
Save krrishd/f75fc21c27811085543b to your computer and use it in GitHub Desktop.
String.prototype.reverse() - A random snippet I made in the console
String.prototype.reverse = function() {
var reversed = [];
for(i=0; i< this.length; i++) {
reversed[this.length - i] = this[i];
}
var rev_str = "";
for(e=0;e<reversed.length;e++) {
rev_str += reversed[e];
}
rev_str = rev_str.replace('undefined', '');
return rev_str;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment