我需要一项活动的帮助。我不断得到同样的错误,因为我不明白为什么会这样。
这是问题,我得到的错误和我的代码。
<html>
<body>
<script type="text/javascript">
// Program name: salesTaxLookup.html
// Purpose:
// Author:
// Date last modified: October 20th 2015
//variables and constants
var salesTax // tax
var purchases; // purchase
var BR = "<br />"; // HTML line break
var PA = "<p />"; // HTML paragraph break
var ES = ""; // empty string for prompt
// welcome the user
document.write("Welcome to sales tax calculator!" + PA);
salesTax = prompt("Enter your total amount of salesTax: ", ES);
salesTax = parseFloat(salesTax);
// calculate
if(salesTax <=0)
if(salesTax<=7) {
document.write("No tax." + BR);
}
else if (salesTax<=21){
document.write("1 cent tax." + BR);
}
else if (salesTax<=35){
document.write("2 cent tax." + BR);
}
else if (salesTax<=49){
document.write("3 cent tax." + BR);
}
else if (salesTax<=64){
document.write("4 cents tax." + BR);
else if (salesTax<=78) {
document.write("5 cents tax." + BR);
}
else if (salesTax<=92) {
document.write("6 cents tax." + BR);
}
else if (salesTax<=99){
document.write("7 cents tax." + BR)
}
</script>
</body>
</html>
&#13;
答案 0 :(得分:2)
您在第39行遇到语法错误,但缺少。
应该是:
else if (salesTax<=64) {
document.write("4 cents tax." + BR);
}