javascript - my write method fails to generate output -


anyone have clue why write method isn't working here? script intended reverse prompt string. nothing extraordinary, write method fails.

js in head

string.prototype.backwards = function(){ var out=''; (var = this.length-1; >= 0; i--) {     out += this.substr(i,1);     } return out; } 

body

var instring=prompt("enter test string: "); document.write(instring.backwards()); 

prompt works. write method fails. code accurate far can tell. use jshint isn't helping. , browser's dev tools didn't pin point anything.

fyi code ch8 of "learn js in 24hrs" kindle version....


Comments