Skip to content

Commit 24f6537

Browse files
committed
Add display json console
1 parent b8b7b41 commit 24f6537

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

projects/tip-calculator/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h1>Tip Calculator</h1>
1414
<table>
1515
<thead>
1616
<tr>
17-
<th>Product</th>
17+
<th>Name</th>
1818
<th>Price</th>
1919
<th>Unit</th>
2020
<th>Money</th>

projects/tip-calculator/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ function calculateTotal() {
7979
finalTipSpan.classList.add("error-highlight");
8080
totalSpan.classList.add("error-highlight");
8181
}
82+
83+
const report = { products: [], tip: tipValue };
84+
85+
for (let row = 0; row < productRows.length; row++) {
86+
const nameValue = productRows[row].children[0].firstElementChild.value;
87+
const priceValue = productRows[row].children[1].firstElementChild.value;
88+
const unitValue = productRows[row].children[2].firstElementChild.value;
89+
const product = { name: nameValue, price: priceValue, unit: unitValue };
90+
report.products.push(product);
91+
}
92+
console.log(report);
8293
}
8394

8495
function cleanTotal() {

0 commit comments

Comments
 (0)