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

183
Visualizações
For loop does not appear to be executing with the slightest sign, does anyone have any solutions?

Strangely the for loop doesn't appear to be called. The alert will say 1 but 2 will not show. There aren't any errors in the console, and online code checkers (Specifically JShint.com) say nothing is wrong at all.

window.onLoad = function() {
    var l = 1;
    const S = "Spawn";
    const N = "Next";
    const K = "Kill";
    const LEVEL = [
        [
            [5, 5],
            [1, 1, 1, 1, 1],
            [1, 0, 0, 0, 1],
            [1, S, K, N, 1],
            [1, 0, 0, 0, 1],
            [1, 1, 1, 1, 1]
        ]
    ]
    const PSIZE = 54;
    var SCR = document.getElementById("SCR");
    const context = SCR.getContext("2d");
    drawMap();
}

function drawMap() {
    let w = LEVEL[l - 1][0][0];
    let h = LEVEL[l - 1][0][1];
    alert("1")
    for(let lx = 0; lx == w - 1; lx += 1) {
        for(let ly = 1; ly == h; ly += 1) {
            let tile = LEVEL[l - 1][ly][lx];
            switch(tile) {
                case 1:
                    context.fillColor = "grey";
                    break;
                case 0:
                    context.fillColor = "white";
                    break;
                default:
                    context.fillColor = "red";
                    break;
                    
            }
            alert(2)
            context.fillRect(((lx + 1) * PSIZE), ((ly + 1) * PSIZE), PSIZE, PSIZE);
        }
    }
}

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