+ 3

What is this error with JavaScript

How can JavaScript consider addition in it ?! https://code.sololearn.com/W3z8Rwe40oSK/?ref=app

30th Dec 2017, 7:33 AM
Rocky
Rocky - avatar
4 Answers
+ 5
Do this too: var x=prompt("Enter the first Number"); var y=prompt("Enter the second Number"); document.write((+x + +y)+"<br>"); document.write(x*y)
30th Dec 2017, 7:53 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar
+ 6
the problem is with line document.write(x+y+"<br>"); because x and y are working as a string try this šŸ‘‡šŸ‘‡šŸ‘‡ x=parseInt(x); y=parseInt(y); and then document.write((x+y)+"<br>");
30th Dec 2017, 7:42 AM
MR Programmer
MR Programmer - avatar
+ 5
The + infront of the string is equivalent to the parseInt
30th Dec 2017, 7:54 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar
0
@Mr. Programmer it says "parselnt" is not defined
30th Dec 2017, 11:18 AM
Rocky
Rocky - avatar