jquery - toFixed method doesn't work on user input but works on other vars in javascript, snippet included -
i wanted feedback on why tofixed not work in js alert when attached user input var usergb. curious thing. i've been encouraged post , did not see other questions out here regarding tofixed issues user-input vars.
var downloadspeed = function () { var usergb = prompt("how many gigabytes wish download @ 56 kilobits per second?"); console.log(usergb); var hours = (usergb*8388608)/201600; console.log(hours); var days = (usergb*8388608)/4838400; console.log(days); //below in alert see it, after first concatenated string, i'd type usergb.tofixed(2) won't take. alert("the number of hours take download " + usergb + " gb file @ 56 kilobits per second " + hours.tofixed(2) + " hours. might big number. so, in terms of days download, it'll take " + days.tofixed(2) + " days download. why have faster broadband speeds nowadays , why have video streaming."); } downloadspeed(); the error is not function.
grazie, lou
you need cast input number:
var usergb = +prompt("how many gigabytes wish download @ 56 kilobits per second?");
Comments
Post a Comment