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

89
Views
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
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!