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

93
Views
I keep getting undefined. Before the result shows

let bigo = [[1,2,3],[4,5,6],[7,8,9]];

for(let i = bigo.length; i >= 0; i--){
  console.log(bigo[i]);
}

Result:

> undefined
> [ 7, 8, 9 ]
> [ 4, 5, 6 ]
> [ 1, 2, 3 ]

I keep getting undefined before the result show. What am I doing wrong.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

The last index is length - 1, not length, which is why your first result will be out of bounds and show undefined.

about 4 years ago · Juan Pablo Isaza Report

0

bigo is 3 items long but does not have anything at index position 3. This is because indices count from 0. You need to write let i = bigo.length - 1

about 4 years ago · Juan Pablo Isaza Report

0

Save yourself the hassle and stop using index-based loops.

let bigo = [[1,2,3],[4,5,6],[7,8,9]];

for (let arr of [...bigo].reverse()) {
  console.log(arr);
}

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!