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

189
Views
Significance of ';' after for loop condition in JS
const arr = []
for(let i=0 ; i<=5 ; i++ );{
  arr.push(i)
 }
console.log(arr)

Can anyone explain me this scenario ?

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

0

I just rewrite above code. In for loop i will be increase from 0 to 5, when i reaches to 6, it will be return through i<=5. and push 6 to arr. that's it.

const arr = []
for(var i=0 ; i<=5 ; i++){} // i will be from 0 to 6.
{ 
  arr.push(i)
}
console.log(arr) // [6]

about 4 years ago · Juan Pablo Isaza Report

0

The semicolon between round bracket and curly stops the statement.

about 4 years ago · Juan Pablo Isaza Report

0

You can do the following:

  • If you are trying to push the numbers 0 to 5 into the array, then remove the semicolon (;), else it will cause reference error since i is a let variable.
  • If you want to push only the last value of i (which is 6) then please use var instead of let inside for loop.
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!