+ 3

Help with code JS

https://code.sololearn.com/W6P02P26P63C/?ref=app var a=prompt("number") var b=prompt("number") var c=a+b console.log(a+"+"+b+"="+c) 1+1=11

7th Jan 2018, 9:13 AM
Liluxa
Liluxa - avatar
4 Answers
+ 20
console.log("Console.log v1.0.0") name=prompt("Your name") console.log("Hello "+name+"!") var a=prompt("number") var b=prompt("number") var c=a*1+b*1 console.log(a+"+"+b+"="+c) //prompt returns strings, you have to convert them to numbers to do numeric operations... Number(n), n*1, n/1...
7th Jan 2018, 9:22 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 8
@ILYA use parseInt() function when asking for a number i.e. prompt a and b. I have edited your code in my version. See it. And also use ; semicolon in the end of the statements. https://code.sololearn.com/Wl4Wghz5Cv9e/#html
7th Jan 2018, 9:26 AM
Akash Pal
Akash Pal - avatar
+ 4
thanks
7th Jan 2018, 9:26 AM
Liluxa
Liluxa - avatar
+ 4
A simple way to solve thus issue, try change to this: var c=+a+ +b
7th Jan 2018, 10:09 AM
CalviŐ˛
CalviŐ˛ - avatar