+ 1
Add variables
I want to add two variables but I am unable I put the add sign between variables but the don't add up simply they are written here is the code you can see https://code.sololearn.com/Wl3lRhhh73Xl/?ref=app
4 Réponses
+ 1
Prompt returns a string ,and usuage of "+" on strings concatenates them ,instead cast the result to int and then perform addition ,
w=parseInt(prompt())
+ 1
Input return you data in string form that why + is acting as concatinator.
For maths do it as
var c = parseInt(w)+parseInt(y);
+ 1
The problem solved thanks to both
0
ParseInt is not defined