I am trying to filter out countries in an array of objects with unique currency. The country array structure is
[
{
country: "A",
currencies: [{code: "USD"}, {code: "EURO"}]
},
{
country: "B",
currencies: [{code: "AFN"}]
},
{
country: "C",
currencies: [{code: "CND"}, {code: "EURO"}]
},
{
country: "D",
currencies: [{code: "USD"}]
}
]
What I'm trying to achieve is to filter the country array such that the output array contains only countries with unique value like
[
{
country: "B",
currencies: [{code: "AFN"}]
},
{
country: "C",
currencies: [{code: "CND"}, {code: "EURO"}]
}
]
The countries A and D have both non-unique currency values. In case of country C, even though EURO is non unique, it's other currency code CND is an unique value. I had used array filter method but couldn't find a solution. Any help is appreciated.