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

211
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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