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

224
Views
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.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

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.

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!