Skip to content

Commit d6c1dba

Browse files
committed
Modify report
1 parent 24f6537 commit d6c1dba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

projects/tip-calculator/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,16 @@ function calculateTotal() {
8080
totalSpan.classList.add("error-highlight");
8181
}
8282

83-
const report = { products: [], tip: tipValue };
83+
const report = { products: [], tip: parseFloat(tipValue) };
8484

8585
for (let row = 0; row < productRows.length; row++) {
8686
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;
87+
const priceValue = parseFloat(
88+
productRows[row].children[1].firstElementChild.value
89+
);
90+
const unitValue = parseInt(
91+
productRows[row].children[2].firstElementChild.value
92+
);
8993
const product = { name: nameValue, price: priceValue, unit: unitValue };
9094
report.products.push(product);
9195
}

0 commit comments

Comments
 (0)