How do I convert a alert box to a number in JS
So, I am trying to make a program that takes user input from an alert prompt and then uses another on to ask what operation it will use(*,/,-,+) then gets another number...but when i do it, for example, it adds the numbers as strings, so 2+2 is 22, and not 4...
Yeah, because it returns a string. You need to convert it into a number:
let a = Number(prompt("num 1")); let b = Number(prompt("num 2")); alert(a + b);
Just wanted to highlight something about
parseFloat with base/radix 10.