0
The return of prompt is by default String
correct? The function Number
does the prompt return conversion which is String to number. Pq then when I run the following function and place numbers between quotation marks NaN
, should not convert the return to number and run the calculation?
var num = Number(prompt("Digite um número", ""));
alert("Seu número é a raíz quadrada de " + num * num);
Here ta working. Input: 10; Output: Your number is the square root of 100
– Francisco
Tries to put the value in quotes, a String.
– LeAndrade
Leandrade, it’s like you said, the return of a prompt is a string by default. Putting 12 or "12" will be string anyway. The difference is that you can convert 12 directly, and "12" does not.
– Francisco