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

204
Views
How do I convert a list to local storage and convert back to the same variable?
    let grid = [];
    function redirect()
    {
        localStorage.setItem("newGrids", JSON.stringify(grid));
        window.location.href = 'easterEgg.html';
    }
    
    function makeTable()
    {
        if (localStorage.newGrids) 
        {
            var retrievedData = localStorage.getItem("newGrids");
            grid = JSON.parse(retrievedData);
        {
        else 
       {
            for (let row = 0; row < numRows; row++)
            {
               let temp = [];
               for (let col = 0; col < numCols; col++)
            {
               temp.push(new GuessCell('-'));
            }
               grid.push(temp);
           }   
      }

Here is the code. I want to assign the value of "grid" to "newGrids"(in local storage) when the code goes to a new page and then put the value back into "grid" when the page loads again. The code is not saving the grid when run.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This line feels odd in the code. You can't use the localStorage object like this.

if (localStorage.newGrids)

Other than that the code looks fine. Unless the rows are not having any data, the grid value would have stored.

about 4 years ago · Juan Pablo Isaza Report
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!