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

203
Visualizações
how do I make a 2d array function

Im trying to make a function that makes a 2d array but I have a syntax error here is the function

function asdf(col,row)
{
    let arr = new Array(col);
    let i = 0;
    for (i < col; i++)
    {
        arr[i] = new Array(row);
    }
    return arr;
}

the error is at the ")" at the end of the for loop any ideas?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The error is due to a missing semi-colon in the for loop:

for (i < col; i++)

Change it to

for (;i < col; i++)

A better approach can be just to simply define the loop variable in the for loop like so:

for (let i = 0;i < col; i++)
about 4 years ago · Juan Pablo Isaza Relatório

0

The for statement creates a loop with 3 optional expressions:

for (expression 1; expression 2; expression 3) {
  // code block to be executed
}

Expression 1 is executed (one time) before the execution of the code block.

Expression 2 defines the condition for executing the code block.

Expression 3 is executed (every time) after the code block has been executed.

There's a syntax error because you are missing Expression 1.

about 4 years ago · Juan Pablo Isaza Relatório
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