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

367
Views
How Do I grab values from multiple object in a JSON format and store them in an array?

I have an array of objects in a JSON format:

[
  {
    "word": "turkey"
  },
  {
    "word": "tiger"
  },
  {
    "word": "horse"
  },
  {
    "word": "pig"
  },
  {
    "word": "dog"
  },
  {
    "word": "cat"
  }
]

I want to extract the value for each "word" key and store it into an array like so:

let wordsArray = ["turkey", "tiger", "horse", "pig", "dog", "cat"];
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You just need to map the values:

console.log([
  {
    "word": "turkey"
  },
  {
    "word": "tiger"
  },
  {
    "word": "horse"
  },
  {
    "word": "pig"
  },
  {
    "word": "dog"
  },
  {
    "word": "cat"
  }
].map( ({word}) => word ))

about 4 years ago · Juan Pablo Isaza Report

0

You can use Array.map to extract the value of the word property:

const arr = [
  {
    "word": "turkey"
  },
  {
    "word": "tiger"
  },
  {
    "word": "horse"
  },
  {
    "word": "pig"
  },
  {
    "word": "dog"
  },
  {
    "word": "cat"
  }
]

const res = arr.map(e => e.word);
console.log(res);

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!