0

Why when I enter data by "prompt" and want to add it add up as text strings?

And how can I fix it? I mean, how can I turn that string into a number?

12th Jul 2020, 2:57 PM
Sam Vásquez
Sam Vásquez - avatar
2 Respostas
+ 6
It happens because prompt by default returns String. To convert it to number you can simply use the Number() for example: var xyz = Number(prompt())
12th Jul 2020, 3:08 PM
Raj Chhatrala
Raj Chhatrala - avatar