Reputation: 1
I'm trying to create a program to calculate (initial price-discount+shipping)*tax. I have to use alert and prompt function, but my alert function doesn't seem to work...I've tried moving it and generally copy/pasting frantically (evident in the code), but it seems that the code just doesn't run all the way through.
<!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>
Upvotes: 0
Views: 52
Reputation: 177
I see a few problems:
<body>
tags<html>
tag'
or "
==
or ===
(strict equality).=
is used for assignmentsI'd suggest to go back and learn the basics first.
Upvotes: 1
Reputation: 13682
That needs to be location === 'NJ'
and location === 'NY'
.
I don't know if that's all that's wrong, but you need to fix that to start.
Upvotes: 0