JavaScript - Optimizing a two array.map loop I have to iterate two arrays, if the iso propery of the first array is equal to address.country of the second array condition is verified, assign address and slug of the second array (this.concessions) to the first array (this.countries).

at the end, you need to have a new this.countries array that contains theaddress and slug property (in addition to the properties he already had)

this.countries.map((element) =&gt; {
  this.concessions.map((value) =&gt; {
    if (element.iso === value.address.country) {
      element.address = value.address
      element.slug = value.slug
    }
  })
})


How can I optimize this, and for this case what is the best iterable to use, for ..of for example ?
That'd be with map:

this.countries = this.countries.map(country =&gt; {
    var concession = concessions.find(x =&gt; x.address.country === country.iso);
    country.address = concession.address;
    country.slug = concession.slug;
    return country;
});


That'd be with forEach:

this.countries.forEach(country =&gt; {
    var concession = concessions.find(x =&gt; x.address.country === country.iso);
    country.address = concession.address;
    country.slug = concession.slug;
});


I don't know if you can be sure there always be a concession for each country and how you should proceed in case there isn't.