[Vuejs]-Vue JS – Calculator – read output string as value

0👍

parseInt() is not a method of the String prototype but rather a built-in function.

Update this line:

this.currentNum = this.output.parseInt();

to this:

this.currentNum = parseInt(this.output);

And it is a good idea to specify the radix in the second parameter – perhaps 10 in most all cases, for decimal numbers:

this.currentNum = parseInt(this.output, 10);

That way, if a value like 022 is entered, it isn’t interpreted as the octal value (I.e. Decimal number 18).

Leave a comment