I have an array of objects containing the keys name
and isPinned
. My goal is to create a new array that stores only the country names based on the value of isPinned
. For instance, if Australia and China are marked as true for isPinned
, then the resulting array would be:
const countriesFiltered = ["Australia", "China"]
const countries = [
{ name: "Australia", isPinned: true },
{ name: "China", isPinned: true },
{ name: "India", isPinned: false },
];