Fixed critical math bug
This commit is contained in:
+5
-2
@@ -162,7 +162,7 @@ let addCurrency = () => {
|
|||||||
};
|
};
|
||||||
// Check that the rate is a number
|
// Check that the rate is a number
|
||||||
if (isNaN(newCurrency.rate)) {
|
if (isNaN(newCurrency.rate)) {
|
||||||
alert("DKK exchange rate is now a number");
|
alert("DKK exchange rate is not a number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update with the new currency, and refresh the table
|
// Update with the new currency, and refresh the table
|
||||||
@@ -208,7 +208,10 @@ let updateTable = () => {
|
|||||||
// Populate a tbody with subscriptions from the subscriptions array.
|
// Populate a tbody with subscriptions from the subscriptions array.
|
||||||
let populateTable = (tbody) => {
|
let populateTable = (tbody) => {
|
||||||
// Store the total cost of all subscriptions
|
// Store the total cost of all subscriptions
|
||||||
let total = subscriptions.map((s) => s.monthly).reduce((acc, sub) => acc + sub);
|
if (subscriptions.length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let total = subscriptions.map((s) => s.indkk).reduce((acc, sub) => acc + sub);
|
||||||
// Update tablefoot with total monthly cost and amount of subscriptions.
|
// Update tablefoot with total monthly cost and amount of subscriptions.
|
||||||
document.querySelector('#total').innerHTML = total.toFixed(2);
|
document.querySelector('#total').innerHTML = total.toFixed(2);
|
||||||
document.querySelector('#amountOfSubscriptions').innerHTML = subscriptions.length.toString();
|
document.querySelector('#amountOfSubscriptions').innerHTML = subscriptions.length.toString();
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-2
@@ -233,7 +233,7 @@ let addCurrency = () => {
|
|||||||
|
|
||||||
// Check that the rate is a number
|
// Check that the rate is a number
|
||||||
if (isNaN(newCurrency.rate)) {
|
if (isNaN(newCurrency.rate)) {
|
||||||
alert("DKK exchange rate is now a number")
|
alert("DKK exchange rate is not a number")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,10 @@ let updateTable = () => {
|
|||||||
// Populate a tbody with subscriptions from the subscriptions array.
|
// Populate a tbody with subscriptions from the subscriptions array.
|
||||||
let populateTable = (tbody) => {
|
let populateTable = (tbody) => {
|
||||||
// Store the total cost of all subscriptions
|
// Store the total cost of all subscriptions
|
||||||
let total = subscriptions.map((s) => s.monthly).reduce((acc, sub) => acc + sub)
|
if (subscriptions.length <= 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let total = subscriptions.map((s) => s.indkk).reduce((acc, sub) => acc + sub)
|
||||||
|
|
||||||
// Update tablefoot with total monthly cost and amount of subscriptions.
|
// Update tablefoot with total monthly cost and amount of subscriptions.
|
||||||
document.querySelector('#total').innerHTML = total.toFixed(2);
|
document.querySelector('#total').innerHTML = total.toFixed(2);
|
||||||
|
|||||||
Reference in New Issue
Block a user