我在运行此代码时收到一个NaN
错误。我一直在试图找出为什么现在有一段时间,不能为我的生活。JavaScript NaN错误循环
为了澄清,我试图接受;
客户
应付总金额有多少客户在进入
function Summarise() { ID = prompt("Enter a Customer ID number ", -1) while(ID != -1) { var gasUsed = 0 var total = 0 gasUsed = prompt("Enter amount of gas used ", "0") ///Standard Rate is used to assist in the calculation of customers in excess of 60 Gas Used StandardRate = 60 * 1.75 if(gasUsed <= 60) { total= gasUsed * 2 document.write("Customers ID: " + ID) document.write(" has gas usage of " + gasUsed) document.write(" and owes $" + total) document.write("<br/>") } else { total= (gasUsed - 60) * 1.50 + StandardRate document.write("Customers ID: " + ID) document.write(" has gas usage of " + gasUsed) document.write(" and owes $" + total) document.write("<br/>") } var totalowed = total + totalowed var totalcustomers = ++totalcustomers ID = prompt("Enter a Customer ID number ", -1) } document.write("Total amount owed $" + totalowed) document.write("<br/>") document.write("Total Number of customers:" + totalcustomers) }
这是因为你使用了一些变量,它是不确定的,并提供明确的值.. – DeDevelopers 2014-09-29 11:50:27
快速提示:分号不(真的)可选。 – 2014-09-29 11:51:59
我还是非常非常新的JavaScript,你能多解释一下@ DeDevelopers – 2014-09-29 11:57:50