0
10th May 2022, 7:35 PM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
7 odpowiedzi
+ 1
use parseInt(or parseFloat), like these : res = parseInt(a) + parseInt(b) or input=parseInt (prompt(...))
10th May 2022, 7:41 PM
Xushnudbek Isaqov
Xushnudbek Isaqov - avatar
+ 1
const input1 = Number(prompt("Enter first num: ")); const operator = prompt("Enter an operator"); const input2 = Number(prompt("Enter second num: "));
10th May 2022, 8:21 PM
JaScript
JaScript - avatar
0
It working like concatination because prompt accept string type basically.. Convert into into number type value by const input1 = Number(prompt("Enter first num: ")); Or const input2 = +prompt("Enter first num: "); Both value.. For, other it will automatically converted but for plus, it works both ways : addition and concatination overloaded operator... Hope it helps...
10th May 2022, 7:43 PM
Jayakrishna 🇮🇳
0
Xushnudbek Isaqov Jayakrishna🇮🇳 I tried your recommendation but unfortunately not working still.
10th May 2022, 7:52 PM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
0
What have you tried? How you tried it? It works. . All 3 ways.. Do check again. edit: Muhammad Abdulmalik convert input1 and input2 into number
10th May 2022, 7:54 PM
Jayakrishna 🇮🇳
0
use it only for numbers not for operator
10th May 2022, 7:56 PM
Xushnudbek Isaqov
Xushnudbek Isaqov - avatar
0
Hi Muhammad Abdulmalik update your code with what you have tried. Just reopen it add your changes and save. Then we can see why its not working :) Thanks
10th May 2022, 11:47 PM
Chris Coder
Chris Coder - avatar