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

100
Views
cómo almacenar mis datos en el almacenamiento local como objeto de lo que tengo

Dos botones que cuentan y almacenan datos en el almacenamiento local, solo intento que se almacene como obj en el almacenamiento local, pero soy un novato y no pude hacerlo funcionar, ¿alguien puede explicar cómo hacerlo con lo que tengo? ¡gracias! No sé si puedo agregar esto aquí o necesito hacerlo desde cero.

 const wellbtn = document.querySelector('.wellbtn'); const unwellbtn = document.querySelector('.unwellbtn'); const moodwell = document.querySelector('.moodwell') const moodunwell = document.querySelector('.moodunwell') let wellcounter = localStorage.getItem('wellcounter'); let unwellcounter = localStorage.getItem('unwellcounter'); moodwell.innerText = `You felt well ${wellcounter} times`; moodunwell.innerText = `You felt unwell ${unwellcounter} times`; const addWellCounter = (() => { moodwell.innerText = `You felt well ${++wellcounter} times` localStorage.setItem('wellcounter', wellcounter.toString()); }) const addUnwellCounter = (() => { moodunwell.innerText = `You felt unwell ${++unwellcounter} times` localStorage.setItem('unwellcounter', unwellcounter.toString()); }) wellbtn.addEventListener('click', () => { addWellCounter(); }) unwellbtn.addEventListener('click', () => { addUnwellCounter(); });
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My title</title> </head> <body> <h1>How do you feel ?</h1> <button class="wellbtn">Well</button> <button class="unwellbtn">Unwell</button> <p class="moodwell">You felt well 0 times</p> <p class="moodunwell">You felt unwell 0 times</p> </body> </html>

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!