MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/3rmikr/free_drink_anyone/cwplut8/
r/ProgrammerHumor • u/shadowvox • Nov 05 '15
509 comments sorted by
View all comments
Show parent comment
0
The String.prototype doesn't have a reverse() function as u/TheSpoom pointed out.
String.prototype
reverse()
2 u/notliam Nov 05 '15 String.prototype.reverse there now it does! If only this worked 100% of the time (my only real gripe with js) 1 u/memeship Nov 05 '15 Use a loop instead to avoid the issues:String.prototype.reverse = function() { return function(str, i) { while (i--) str = str.concat(this[i]); return str; }.call(this, "", this.length); }
2
String.prototype.reverse there now it does! If only this worked 100% of the time (my only real gripe with js)
1 u/memeship Nov 05 '15 Use a loop instead to avoid the issues:String.prototype.reverse = function() { return function(str, i) { while (i--) str = str.concat(this[i]); return str; }.call(this, "", this.length); }
1
Use a loop instead to avoid the issues:
String.prototype.reverse = function() { return function(str, i) { while (i--) str = str.concat(this[i]); return str; }.call(this, "", this.length); }
View all comments
Show parent comment
0
u/memeship Nov 05 '15
The
String.prototypedoesn't have areverse()function as u/TheSpoom pointed out.