my js code: // Define arrays for income and expenses let income = [ { name: 'Salary', amount: 4000, recurring: true }, { name: 'Freelance Work', amount: 1000, recurring: false }, { name: 'Gift', amount: 50, recurring: false }, { name: 'Bonus', amount: 500, recurring: true }, { name: 'Investment Income', amount: 200, recurring: true } ];   let expenses = [ { name: 'Rent', amount: 1500, recurring: true }, { name: 'Groceries', amount: 350, recurring: true }, { name: 'Utilities', amount: 200, recurring: true }, { name: 'Transportation', amount: 100, recurring: true }, { name: 'Entertainment', amount: 50, recurring: false } ];   // Function to display the income list function displayIncome() { let table = document.createElement('table'); let totalIncome = 0;   for (let i = 0; i < income.length; i++) { let row = document.createElement('tr'); let nameCell = document.createElement('td'); nameCell.textContent = income[i].name; let amountCell = document.createElement('td'); amountCell.textContent = 'R' + income[i].amount; let recurringCell = document.createElement('td'); recurringCell.textContent = income[i].recurring ? 'Yes' : 'No';   row.appendChild(nameCell); row.appendChild(amountCell); row.appendChild(recurringCell); table.appendChild(row);   totalIncome += income[i].amount; }   let incomeList = document.getElementById('income-list'); incomeList.innerHTML = ''; incomeList.appendChild(table);   return totalIncome; }   // Function to display the expense list function displayExpenses() { let table = document.createElement('table'); let totalExpenses = 0;   for (let i = 0; i < expenses.length; i++) { let row = document.createElement('tr'); let nameCell = document.createElement('td'); nameCell.textContent = expenses[i].name; let amountCell = document.createElement('td'); amountCell.textContent = 'R' + expenses[i].amount; let recurringCell = document.createElement('td'); recurringCell.textContent = expenses[i].recurring ? 'Yes' : 'No';   row.appendChild(nameCell); row.appendChild(amountCell); row.appendChild(recurringCell); table.appendChild(row);   totalExpenses += expenses[i].amount; }   let expensesList = document.getElementById('expenses-list'); expensesList.innerHTML = ''; expensesList.appendChild(table);   return totalExpenses; }   // Add income button event listener let addIncomeButton = document.getElementById('add-income-button'); addIncomeButton.addEventListener('click'), function() { let name = prompt('Enter income name:'); let amount = parseInt(prompt('Enter income amount:')); let recurring = confirm('Is income recurring?');   let newIncome = { name: name, amount: amount, recurring: recurring };   income.push(newIncome);   let totalIncome = displayIncome(); let totalExpenses = displayExpenses(); let disposableIncome = totalIncome - totalExpenses;   let savings = parseInt(prompt('How much would you like to save?')); let remainingDisposableIncome = disposableIncome - savings;   alert('Your total disposable income is R' + disposableIncome + ', and your remaining disposable income after saving R' + savings); }   my html: Budgeting Website Budgeting Website Add Income Add Expense Total Disposable Income: Calculate Savings lecturers comment: The id's assigned to the buttons are not matching the id's provided in your javascript to add the event listeners. PLEASE HELP ME FIX ACCORDING TO LECTURERS COMMENT

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

my js code:

// Define arrays for income and expenses

let income = [

{ name: 'Salary', amount: 4000, recurring: true },

{ name: 'Freelance Work', amount: 1000, recurring: false },

{ name: 'Gift', amount: 50, recurring: false },

{ name: 'Bonus', amount: 500, recurring: true },

{ name: 'Investment Income', amount: 200, recurring: true }

];

 

let expenses = [

{ name: 'Rent', amount: 1500, recurring: true },

{ name: 'Groceries', amount: 350, recurring: true },

{ name: 'Utilities', amount: 200, recurring: true },

{ name: 'Transportation', amount: 100, recurring: true },

{ name: 'Entertainment', amount: 50, recurring: false }

];

 

// Function to display the income list

function displayIncome() {

let table = document.createElement('table');

let totalIncome = 0;

 

for (let i = 0; i < income.length; i++) {

let row = document.createElement('tr');

let nameCell = document.createElement('td');

nameCell.textContent = income[i].name;

let amountCell = document.createElement('td');

amountCell.textContent = 'R' + income[i].amount;

let recurringCell = document.createElement('td');

recurringCell.textContent = income[i].recurring ? 'Yes' : 'No';

 

row.appendChild(nameCell);

row.appendChild(amountCell);

row.appendChild(recurringCell);

table.appendChild(row);

 

totalIncome += income[i].amount;

}

 

let incomeList = document.getElementById('income-list');

incomeList.innerHTML = '';

incomeList.appendChild(table);

 

return totalIncome;

}

 

// Function to display the expense list

function displayExpenses() {

let table = document.createElement('table');

let totalExpenses = 0;

 

for (let i = 0; i < expenses.length; i++) {

let row = document.createElement('tr');

let nameCell = document.createElement('td');

nameCell.textContent = expenses[i].name;

let amountCell = document.createElement('td');

amountCell.textContent = 'R' + expenses[i].amount;

let recurringCell = document.createElement('td');

recurringCell.textContent = expenses[i].recurring ? 'Yes' : 'No';

 

row.appendChild(nameCell);

row.appendChild(amountCell);

row.appendChild(recurringCell);

table.appendChild(row);

 

totalExpenses += expenses[i].amount;

}

 

let expensesList = document.getElementById('expenses-list');

expensesList.innerHTML = '';

expensesList.appendChild(table);

 

return totalExpenses;

}

 

// Add income button event listener

let addIncomeButton = document.getElementById('add-income-button');

addIncomeButton.addEventListener('click'), function() {

let name = prompt('Enter income name:');

let amount = parseInt(prompt('Enter income amount:'));

let recurring = confirm('Is income recurring?');

 

let newIncome = {

name: name,

amount: amount,

recurring: recurring

};

 

income.push(newIncome);

 

let totalIncome = displayIncome();

let totalExpenses = displayExpenses();

let disposableIncome = totalIncome - totalExpenses;

 

let savings = parseInt(prompt('How much would you like to save?'));

let remainingDisposableIncome = disposableIncome - savings;

 

alert('Your total disposable income is R' + disposableIncome + ', and your remaining disposable income after saving R' + savings);

}

 

my html:

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Budgeting Website</title>

<link rel="stylesheet" href="budget.css">

</head>

<body>

<h1>Budgeting Website</h1>

<div id="income"></div>

<button id="add-income">Add Income</button>

<div id="expenses"></div>

<button id="add-expense">Add Expense</button>

<br><br>

<h3>Total Disposable Income:</h3>

<input type="text" id="total-disposable-income" readonly>

<br><br>

<button id="calculate-savings">Calculate Savings</button>

<script src="budget.js"></script>

</body>

</html>

lecturers comment:

The id's assigned to the buttons are not matching the id's provided in your javascript to add the event listeners.

PLEASE HELP ME FIX ACCORDING TO LECTURERS COMMENT

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education