+ 1
Javascript Math Operator not working!!
Heres my code: var minute = prompt("Minutes : ", "0"); var second = prompt("Seconds : ", "0"); var convert = minute * 60 var wait = convert + second document.write(wait) If you enter 5 min and 30 sec, it displays 30030 instead of 330. Please help!
3 ответов
+ 4
Try this:
var minute = Number (prompt("Minutes : ", "0"));
var second = Number (prompt("Seconds : ", "0"));
+ 1
Worked. Thanks!
+ 1
js provide a lot of type convert. If you use something like that also will work:
convert/1+second/1
+convert++second
it happens because prompt returns string. and if you concatenate two strings "300" and "30" it will be string "30030"