+ 2

I have a messed up JavaScript calculator code, what is wrong?

I have a messed up code that says this: function addition(){ var addinput1 = prompt("enter your first number") var addinput2 = prompt("enter your second number") var adding = addinput1+addinput2 alert(addinput1 + " plus " + addinput2 + " equals " + adding)} Is there something I’m not seeing because it doesn’t work what ever I try

27th Feb 2018, 4:02 AM
Campbell
Campbell - avatar
9 Respostas
+ 3
link to code did you add ; in real code?
27th Feb 2018, 4:04 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 3
Thanks for the tip
27th Feb 2018, 5:34 AM
Campbell
Campbell - avatar
29th Apr 2018, 3:23 PM
Programmer Gaurav
Programmer Gaurav - avatar
+ 2
What?
27th Feb 2018, 4:07 AM
Campbell
Campbell - avatar
27th Feb 2018, 4:09 AM
Campbell
Campbell - avatar
+ 2
https://code.sololearn.com/WLwo3J8hjlHm/?ref=app you needed to use parseInt as it was treating the inputs as strings
27th Feb 2018, 4:18 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 2
Thank you so much
27th Feb 2018, 4:19 AM
Campbell
Campbell - avatar
+ 1
meaning code it here on sololearn then press share then copy link. paste link here
27th Feb 2018, 4:09 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 1
A lil tip: var adding = +addinput1 + +addinput2; This essentially reads the strings as numeric.
27th Feb 2018, 4:23 AM
Michael Simnitt
Michael Simnitt - avatar