String.prototype.reverseStr = function () {
var len = this.length - 1;
var j = 0;
for (i = len; i >= Math.floor(len / 2); i--) {
var tmp = this[i];
this[i] = this[j];
this[j] = tmp;
j++;
}
return this;
}
alert("abcde".reverseStr());
Why doesn't this work ? It outputs "abcde" and not reversed string .