我试图创建一个计算程序(初始价格折扣+运费)*税。我必须使用警报和提示功能,但我的警报功能似乎不起作用...我已经尝试移动它并且通常疯狂地复制/粘贴(在代码中很明显),但似乎代码并没有完全运行。
<!DOCTYPE html>
<html>
<head>
<!-- My Name -->
<title> HW#6 </title>
</head>
<body>
<h1>The Company Store</h1>
<h2>Processing Screen</h2>
</body>
<body>
<script>
function priceCalc(initialPrice, finalPrice, isMember, location) {
return finalPrice;
}
var initialPrice = parseInt(prompt("Enter price"));
var isMember = prompt("Enter Y if you are a member, N if not");
isMember = isMember.toUpperCase();
var location = prompt("enter NJ if you are from New Jersey, NY if from New York");
location = location.toUpperCase();
if (member = Y) {
var finalPrice = price * 0.9;
}
else {
var finalPrice = price; }
if (location = NJ) {
finalPrice = (finalPrice + 5) * (1 + 0.07);
alert("The final price is" + priceCalc(initialPrice, finalPrice, isMember, location));
}
else if (location = NY) {
finalPrice = (finalPrice + 3) * (1 + 0.08);
alert("The final price is" + priceCalc(initialPrice, finalPrice, isMember, location));
}
alert("The final price is" + priceCalc(initialPrice, finalPrice, isMember, location));
</script>
</body>
答案 0 :(得分:1)
我看到一些问题:
<body>
代码<html>
代码'
或"
==
或===
(严格平等)
=
用于分配我建议先回去学习基础知识。
答案 1 :(得分:0)
需要location === 'NJ'
和location === 'NY'
。
我不知道这是否都是错的,但你需要解决这个问题才能开始。