I'm currently working on a JavaScript problem, where I need to add an object to an empty array, 'expenses'. My addExpense function takes two arguments (description, amount), but I can only successfully add the 'amount' value to my empty 'expenses' array. The first argument, 'description' is declared but never read.
What is the reason for this distinction? Here is my code:
const account = {
name: 'John Doe',
expenses: [],
addExpense: function (description, amount) {
this.expenses.push({description: amount})
}
}
account.addExpense('item', 15.00)
The above code will return
expenses: [ { description: 15 } ]
for the array.