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

202
Views
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 answers
Answer question

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 Report

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 Report
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!