Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

88
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda