Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Cómo agregar un objeto por eventListener en JS

Quiero agregar un nuevo objeto de clase newExpense.
gasto1 está funcionando y puedo ver esto en la consola, pero gasto2 no está definido incluso cuando hago clic en el botón.
Necesito que alguien me explique cómo funciona y cómo definir expanse2 haciendo clic en el botón.

 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'); })
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!