0
This code have some kind of error. It does not add numbers. Just display them without adding them. Can somebody explain why?
function bankAccounts(name, coin) { name = prompt("Name, please"); var a = prompt("On your first account you have ", ''); var b = prompt("and on another you have ", ""); coin = a + b; alert( "So " + name + " in total, you have " + coin + " coins."); } bankAccounts()
2 Respuestas
+ 1
prompt() returns a string you have to turn it into an int or float e.g.
var a = parseInt(prompt("On your first account you have"));
Same with string -> float but parseFloat()
0
Thanks! I have to learn a lot, there are more commands then I thought.