budget.js
// removes the expense whose button was clicked from the Expenses column

removes the expense whose button was clicked from the Expenses column
removes the expense whose button was clicked from the Expenses column
function removeItemExpense(id) {
           let aux_name = [];
           let aux_sum = [];
           let aux_necessity = [];
           aux_name = name_expenses.map((x) => x);
           aux_sum = sum_expenses.map((x) => x);
           aux_necessity = expense_necessity.map((x) => x);
           name_expenses = [];
           sum_expenses = [];
           expense_necessity = [];
           index_expense = 1;
           let removeTable = document.getElementById('expensesTable');
           let parentElement = removeTable.parentElement;
           parentElement.removeChild(removeTable);
           document.getElementById("expense").innerHTML = `
                   <h2 class="smallTitle">
                       Expenses
                   </h2>
                   <table id="expensesTable">
                       <td>Name</td>
                       <td>Sum</td>
                       <td>Necessity</td>
                   </table>
           `
           for (let i = 0; i<aux_name.length; i++)
               if(i != id - 1) {
                   name_expenses.push(aux_name[i]);
                   sum_expenses.push(aux_sum[i]);
                   expense_necessity.push(aux_necessity[i]);
                   addExpenseToTable();
               }
               calculateBudget();
               necessityStatistics();
       }
function removeItemExpense ( id ) { let aux_name = [ ] ; let aux_sum = [ ] ; let aux_necessity = [ ] ; aux_name = name_expenses . map ( ( x ) => x ) ; aux_sum = sum_expenses . map ( ( x ) => x ) ; aux_necessity = expense_necessity . map ( ( x ) => x ) ; name_expenses = [ ] ; sum_expenses = [ ] ; expense_necessity = [ ] ; index_expense = 1 ; let removeTable = document . getElementById ( 'expensesTable' ) ; let parentElement = removeTable . parentElement ; parentElement . removeChild ( removeTable ) ; document . getElementById ( "expense" ) . innerHTML = ` ` for ( let i = 0 ; i < aux_name . length ; i ++ ) if ( i != id - 1 ) { name_expenses . push ( aux_name [ i ] ) ; sum_expenses . push ( aux_sum [ i ] ) ; expense_necessity . push ( aux_necessity [ i ] ) ; addExpenseToTable ( ) ; } calculateBudget ( ) ; necessityStatistics ( ) ; }
removes the expense whose button was clicked from the Expenses column
removes the expense whose button was clicked from the Expenses column