I am working on nested array and try to find a value inside the nested array based on another value. I want to find the OptionCode of the currently active filters.
filters = [
{
FilterCode: "TourPrice",
FilterName: "Tour Price",
Options: [
{ Name: "Free", OptionCode: "Free", active: false, blocked: false },
{ Name: "Paid", OptionCode: "Paid", active: false, blocked: false },
{
Name: "Free and Paid",
OptionCode: "FreeAndPaid",
active: true, //Find OptionCode Here
blocked: false,
},
],
},
{
FilterCode: "SortedBy",
FilterName: "Sorted By",
Options: [
{
Name: "Most Relevant",
OptionCode: "MostRelevant",
active: true, // Find OptionCode Here
blocked: false,
},
{
Name: "Latest Tour",
OptionCode: "LatestTour",
active: false,
blocked: false,
},
{
Name: "Oldest Tour",
OptionCode: "OldestTour",
active: false,
blocked: false,
},
{
Name: "Lowest Price",
OptionCode: "LowestPrice",
active: false,
blocked: false,
},
],
},
],
For the above array the expected outcome should be somthing like ["FreeAndPaid","MostRelevant"]