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

118
Views
show the 6th item in a Javascript array

I've got a script that allows me to search my Google Sheets doc and returns a row of items in an array. I've console.logged the results see image but I can't workout how I only (alert) the 6th item?

enter image description here

I know this is basic stuff but I can't work it out on my own.

Here's my code

function showPrice(el, arrayOfArrays, index) {
    const results = arrayOfArrays.filter(r => r[0] === "Dog");
    alert(results[6]);
  }

I get undefined?

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

0

Your filter returns the outer array since its first array's 0th entry is Dog

The outer array's length is 1

So perhaps you want to show the 6th entry of the nested array returns in the filter?

const arr = [
  ["Dog", "Colorbyte", 40, 700, 1, 2, 3, 4]
]

function showPrice(el, arrayOfArrays, index) {
  const results = arrayOfArrays.filter(r => r[0] === "Dog");
  console.log(results.length)
  console.log(results[0][6]);
}

showPrice(null,arr,null)

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!