Created
June 20, 2014 00:29
-
-
Save krrishd/f75fc21c27811085543b to your computer and use it in GitHub Desktop.
String.prototype.reverse() - A random snippet I made in the console
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
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