Skip to content

Commit 5d2259d

Browse files
committed
Updated .js w/getReceipt()
1 parent 0f36f08 commit 5d2259d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function getReceipt() {
2+
// Initializes the string, allowing passage from function to function, growing line by line into a full receipt
3+
var text1 = "<h3>You Ordered:</h3>";
4+
var runningTotal = 0;
5+
var sizeTotal = 0;
6+
var sizeArray = document.getElementsByClassName("size");
7+
for (var i = 0; i < sizeArray.length; i++) {
8+
if (sizeArray[i].checked) {
9+
var selectedSize = sizeArray[i].value;
10+
text1 = text1 + selectedSize + "<br>";
11+
}
12+
}
13+
if (selectedSize === "Personal Pizza") {
14+
sizeTotal = 6;
15+
} else if (selectedSize === "Small") {
16+
sizeTotal = 8;
17+
} else if (selectedSize === "Medium Pizza") {
18+
sizeTotal = 10;
19+
} else if (selectedSize === "Large Pizza") {
20+
sizeTotal = 14;
21+
} else if ((selectedSize = "Extra Large Pizza")) {
22+
sizeTotal = 16;
23+
}
24+
runningTotal = sizeTotal;
25+
console.log(selectedSize + " =$" + sizeTotal + ".00");
26+
console.log("size text1: " + text1);
27+
console.log("subtotal: $" + runningTotal + ".00");
28+
// These variables will get passed on to each function
29+
//getTopping(runningTotal, text1);
30+
}

0 commit comments

Comments
 (0)