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

92
Views
How to reference to specific element in array by its index

Let's suppose we have, for instance:

const array = [1, 0, 1, 1, 0]

In case I do this:

for(const el of array) console.log(array.indexOf(el))

I will always get either 0 or 1 because it will search for the first occurrence that matches the value. How do I refer to the element within an array precisely by its index? That is, how to get "0, 1, 2, 3, 4" in that case? Or even with a more than one dimension array, for example.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Loop through the array and print the index

for(let i = 0; i < array.length; i++){
  array[i] === 1 && console.log(i); 
}
about 4 years ago · Santiago Gelvez 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!