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

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