Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

301
Vistas
Accessing array element from API data

so maybe you've heard of Splinterlands. This is from a bot that I'm trying to customize, but JS is so confusing to me. When I display the array with JSON.stringify(teamToPlay), I get this:

{ 
  "summoner": "167",
  "cards": [167, 162, 192, "", "", "", "", "fire", "", ""]
}

I'm trying to pull out "fire", the 8th element in the cards array. "cards" is an array, right? Appreciate your help.

over 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Let me explain you with another example

const info = {
    firstName: "priyam",
    lastName: "shah",
    birthYear: 1000,
};
console.log(info.firstName);
console.log(info["lastName"]);

This is how you can access objects. Now it's quite easy to find the 8th character from the array right ? arrName[index]

So it should be obj.cards[7] assuming you save this data coming from api to a variable called obj.

over 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Asistente virtual