I want to add new object of class newExpense.
expense1 is working and i can look on this in console but expense2 is not defined even when i click on button.
I need somebody to explain me how it's works and how to define expanse2 by click on button.
const addButton = document.querySelector('.add_btn');
class newExpense {
constructor(name, date, amount) {
this.name = name;
this.date = date;
this.amount = amount;
}
}
const expense1 = new newExpense('Name', 'Some date', 'Amount');
addButton.addEventListener('click', () => {
const expense2 = new newExpense('Name2', 'Some date2', 'Amount2');
})