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

118
Views
How to create array of object from tow arrays with extra properties?

I need help to create an array of objects from two exiting array

["A","B","C"]
[1,2,3] 

What I want is something like the below:

[{name: "A", id: 1, trash: false},{name: "B", id: 2, trash: false},{name: "C", id: 3, trash: false}]

properties should be defined as I want it like name and id and the value of them should come from existing arrays.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Hope this code helping you

const array = ["A","B","C"]
const num = [1,2,3] 
array.map((o,index)=>({name: o,id:num[index],trash:false}))
about 4 years ago · Juan Pablo Isaza Report

0

You can try using Array.prototype.map() that creates a new array populated with the results of calling a provided function on every element in the calling array.

var arr1 = ["A","B","C"]
var arr2 = [1,2,3] 
var resArr = arr1.map((i,idx) => ({name: i, id: arr2[idx], trash: false}));
console.log(resArr);

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!