Preview:
// removes all duplicates of a key in a json array, in this case we create a new const that loops over a cities json array and checks for countries with the same name. it will return only the first instance of that country object where there are multiple of the same country

const countriesUnique = new Set(
  cities.map(city =>
    JSON.stringify({ country: city.country, emoji: city.emoji }),
  ),
)
const countries = [...countriesUnique].map(each => JSON.parse(each))
console.log(countries)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter