budget.js
// calculates and updates the statistics of necessity for expenses

calculates and updates the statistics of necessity for expenses
calculates and updates the statistics of necessity for expenses
function necessityStatistics() {
               let sumExpenseNecessary = 0;
               let sumExpenseOptional = 0;
               for(let i = 0 ; i < sum_expenses.length ; i++){
                   if(expense_necessity[i] == "Optional") 
                       sumExpenseOptional += parseFloat(sum_expenses[i]);
                   else
                       sumExpenseNecessary += parseFloat(sum_expenses[i]);
               }
               sumExpenseNecessary = Math.round((sumExpenseNecessary + Number.EPSILON) * 100) / 100;
               sumExpenseOptional = Math.round((sumExpenseOptional + Number.EPSILON) * 100) / 100;
               let removeNecessities = document.getElementById('necessities');
               let parentElement = removeNecessities.parentElement;
               parentElement.removeChild(removeNecessities);
               document.getElementById("properties").innerHTML = `
               <div id="necessities">
                   <div>Spent on Necessities: `+String(sumExpenseNecessary)+`</div>
                   <div>Optional Spendings: `+String(sumExpenseOptional)+`</div>
               </div>
           `
       }
function necessityStatistics ( ) { let sumExpenseNecessary = 0 ; let sumExpenseOptional = 0 ; for ( let i = 0 ; i < sum_expenses . length ; i ++ ) { if ( expense_necessity [ i ] == "Optional" ) sumExpenseOptional += parseFloat ( sum_expenses [ i ] ) ; else sumExpenseNecessary += parseFloat ( sum_expenses [ i ] ) ; } sumExpenseNecessary = Math . round ( ( sumExpenseNecessary + Number . EPSILON ) * 100 ) / 100 ; sumExpenseOptional = Math . round ( ( sumExpenseOptional + Number . EPSILON ) * 100 ) / 100 ; let removeNecessities = document . getElementById ( 'necessities' ) ; let parentElement = removeNecessities . parentElement ; parentElement . removeChild ( removeNecessities ) ; document . getElementById ( "properties" ) . innerHTML = ` ` + String ( sumExpenseNecessary ) + ` ` + String ( sumExpenseOptional ) + ` ` }
calculates and updates the statistics of necessity for expenses
calculates and updates the statistics of necessity for expenses