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

204
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
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