Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

88
Vistas
condensing JavaScript import localStorage

Below is the code that I came up with to import the values of a key in localStorage and supply each value the key holds into a function. Being that I'm very new to JavaScript, I was wondering if there's a better way to do what I did below and still provide the same outcome ?

Code :

function importStorage() {
    for (let i = 0; i < localStorage.length; i++) {
        const key = localStorage.key(i);             // This references the key
        const values = localStorage.getItem(key)     // This pulls the values associated
        const newValues = values.slice(2, -2)        // This removes this ( and this ) 
        const finalValues = newValues.split("', '")  // This then splits the string
        newBill(finalValues[0], finalValues[1], finalValues[2])
    }
}

Is there a better way to achieve it ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda