I have the following array:
route: [
{
flyFrom: "CDG",
flyTo: "DUB",
return: 0,
},
{
flyFrom: "DUB",
flyTo: "SXF",
return: 0,
},
{
flyFrom: "SFX",
flyTo: "CDG",
return: 1,
}
]
I need to count how many times there is return: 0 and how many times there is return: 1.
The end result would look like:
for the cases where return: 0 appears 2 times --- 1 Stop
for the cases where return: 1 appears 1 time --- Non-stop
returnis a reserved word (also a keyword) in javascript and thus cannot be used as an object's key.