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

87
Vistas
my function does not fill any cases in my array in javascript

I'm trying here to solve a 4x4 skyscraper (link skyscraper game) But the problem is that my function place insert 0 number in tab and I don't understand why console log
Also I want to specify that I get 0 error: see below why console log: view code

Now when I place myself a number for example here 9, it works, in the sense that it fills the cells of the table. But here I get an error on the declaration of x, why? console log console log: view code

I won't post all the code for the sake of readability so here is the main function place:

function    place(tab, consign, pos)
{
    var x = Math.floor(pos / 4);
    var y = pos % 4;

    if (tab[x][y] != 0)
        place(tab, consign, pos + 1);
    else
    {
        for (var index = 1; index <= 4; index++)
        {
            tab[x][y] = 9;
            console.log(tab);
            if (colnline_has_no_double(tab, x, y, index))
            {
                if (x % 4 == 3)
                {
                    if (check_top_range(tab, consign, x) && check_bottom_range(tab, consign, x))
                        place(tab, consign, pos + 1);
                }
                if (y % 4 == 3)
                {
                    if (check_left_range(tab, consign, x) && check_right_range(tab, consign, x))
                        place(tab, consign, pos + 1);
                }
                place(tab, consign, pos + 1);
            }
            else
                tab[x][y] = 0;
            if (is_filled_good(tab, consign))
            {
                set_data_in_input(tab);
                return ;
            }
            index++;
        }
        tab[x][y] = 0;
    }
}
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