+ 2

Why my code dose not perform addition

var ans =Number(a)+Number(c); var a, b, c= prompt ("write equation", "", "", ""); if (b=="+") { alert ("your answer is "+ans); }else { alert("i am not program for this "); }

2nd Oct 2020, 3:14 AM
RD:programmer
RD:programmer - avatar
3 Respuestas
+ 6
You cannot have more then one input field in a prompt ,you have to use them seperately! And before declaring a, b ,c, you can't use them ,it will be undefined. https://code.sololearn.com/WkXnh1w0al0L/?ref=app
2nd Oct 2020, 4:02 AM
chaithra Gowda
chaithra Gowda - avatar
2nd Oct 2020, 5:01 AM
chaithra Gowda
chaithra Gowda - avatar
+ 1
Yes , i try it also ....but when i want to input all the equation in one line what's function can i use ?
2nd Oct 2020, 4:42 AM
RD:programmer
RD:programmer - avatar