-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshop.js
69 lines (54 loc) · 1.73 KB
/
shop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function cartChecker() {
let name;
let item;
name = prompt("What is your name?");
item = prompt("What would you like to buy?");
cartHeader.innerHTML = `Hi ${name}, there is something in your cart!`;
cartParagraph.innerHTML = `You still have an item in your cart. Your ${item} is ready to purchase!`;
}
cartButton.onclick = cartChecker;
function calculateTax() {
let price;
let taxPercent;
let tax;
price = prompt("What is the price of the item in your cart?");
taxPercent = prompt("What is the sales tax in your city? (enter in decimals. For example 10% would be 0.10");
let priceNumber = Number(price);
let taxPercentNumber = Number(taxPercent);
tax = priceNumber * taxPercentNumber;
priceParagraph.innerHTML = `Your total bill is $${priceNumber}`;
taxParagraph.innerHTML = `The sales tax is $${tax} at ${taxPercentNumber*100}%.`;
}
calculateButton.onclick = calculateTax;
function calculateTotalBill(bill) {
let tax, total;
tax = bill * .10;
total = bill + tax;
return total;
}
function whatsTheTotal() {
let userInput, b, t;
userInput = prompt("How much is the price amount?")
b = Number(userInput);
t = calculateTotalBill(b);
alert(t);
}
totalButton.onclick = whatsTheTotal;
function songGuessingGame() {
let userChoice;
let correctAnswer;
correctAnswer = "Summertime";
lowerCaseAnswer = "summertime";
alert("What Gershwin song did Billie Holiday sing?");
userChoice = prompt("Take a guess..");
if (correctAnswer === userChoice) {
alert("..And the living is Easy..");
}
else if (lowerCaseAnswer === userChoice) {
alert("..And the living is Easy..");
}
else {
alert("Oops! Try again!")
}
}
song.onclick = songGuessingGame;