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

108
Views
How to merge 2 arrays of object with extra matching

I actually don't know what this is called, hence the "extra matching" in the title

I have 2 arrays of objects

[{player_1: 'adeshina'}, {player_1: 'MindReaper'}]

and

[{player_2: 'thinkerbull'}, {player_2: 'AfroGamer'}]

How can I merge it to become {player_1: 'adeshina', player_2: 'thinkerbull'}, {player_1: 'MindReaper', player_2: 'AfroGamer'} ?

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

0

You can use map() to loop through the arrays and merge the objects,

like this:

const arrayOne = [{player_1: 'adeshina'}, {player_1: 'MindReaper'}]
const arrayTwo = [{player_2: 'thinkerbull'}, {player_2: 'AfroGamer'}]

const newArray = arrayOne.map( (e, index) => ({...e, ...arrayTwo[index]}));
about 4 years ago · Juan Pablo Isaza Report

0

It's actually called "zipping". You wanna zip two arrays.

It can be done using map:

var a = [{player_1: 'adeshina'}, {player_1: 'MindReaper'}]
var b = [{player_2: 'thinkerbull'}, {player_2: 'AfroGamer'}]


var c = a.map(function(e, i) {
  return [e, b[i]];
});

console.log(c)

A shorter version would be:

c = a.map((e, i) =>[e, b[i]]);
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!