I wrote a JS constructor which reverse a string variable:
function ReverseString(string) {
this.str = string;
var size = this.str.length;
this.reverse = function () {
for(size; size >= 0; --size) {
console.log(this.str[size]);
}
}
}
When I invoke a reverse method on a new string object("asd"
) it produces the following output:
undefined
d
s
a
Where this undefined
came from? Could you help me eliminate this ?