I have two arrays with objects containing countries and their country code. One of the arrays have the countries in English and also have key with the country's isoCode. It looks like:
[{
"name": "Denmark",
"dialCode": "+45",
"isoCode": "DK",
},
{
"name": "Germany",
"dialCode": "+49",
"isoCode": "DE",
}]
The other array has the country names in Danish and the dialcode but without the isoCode.
[{
"name": "Danmark",
"dialCode": "+45",
},
{
"name": "Tyskland",
"dialCode": "+49",
}]
Now I want to move/copy the isoCode from the English array to the Danish, matched by the dialCode. But I am a little lost on how to do this.
I have a matching with this
let result = this.dkList.filter(country1 => this.countryList.some(country2 => country2.dialCode === country1.dialCode.replace('00 ', '+').trim()))
My expected result should be
[{
"name": "Danmark",
"dialCode": "+45",
"isoCode": "DK"
},
{
"name": "Tyskland",
"dialCode": "+49",
"isoCode": "DE"
}
]