I am working with two arrays of objects that look like this:
objects [ { countMedias: 2 },
{ countMedias: 1 },
{ countMedias: 3 },
{ countMedias: 1 },
{ countMedias: 2 } ]
listePlayliste [ { nom_playlist: 'bbbb' },
{ nom_playlist: 'ccc' },
{ nom_playlist: 'aaaa' },
{ nom_playlist: 'xxxx' },
{ nom_playlist: 'resttttttttt' } ]
My goal is to merge both arrays to create a new array structured as follows:
Result [ { nom_playlist: 'bbbb', countMedias: 2 },
{ nom_playlist: 'ccc', countMedias: 1 },
{ nom_playlist: 'aaaa', countMedias: 3 },
{ nom_playlist: 'xxxx', countMedias: 1 },
{ nom_playlist: 'resttttttttt', countMedias: 2 } ]
I attempted the following approach, but it did not yield the desired result:
Array.prototype.push.apply(json,objects);