Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda