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

93
Views
Create a key value par in a nested array

How do I create another key value par in a nested array that is unique in this map function? the variable data would have the key as well

let data =  props.json_logs.json_logs?.map?.((item, X) => ({
    ...item,
    id: item._id + X,
    
}));

the json_logs looks like this:

json_logs: Array(13)
0: {_id: '628905742650b2d5a1641f8f', Hostname: 'TT', Results: [{ something: 'something' },{ something: 'something'} ]}
1: {_id: '628cdc277a208e5e39c8bb80', Hostname: 'GG', Results: [{ something: 'something' }]}
2: {_id: '628cdc357a208e5e39c8bb82', Hostname: 'FF', Results: [{ something: 'something' }]}

I am trying to put an id: value pair into the Results array but also keep the other ID in the previous map function

So it shoult look like this

  json_logs: Array(13)
    0: {_id: '628905742650b2d5a1641f8f', Hostname: 'TT', Results: [{id:'628cdbb67a208e5e39c8bb7', something: 'something' },{id:'628cdbb67a208e5e39c8bb7b', something: 'something'} ]
about 4 years ago · Juan Pablo Isaza
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!