I have an array of object called shows:
const shows = [{
"name": "John Doe Show",
"rating": 1234,
"alternative_name": null,
},
{
"name": "Jane Doe Show",
"rating": 4321,
"alternative_name": "Alternate Name 2",
}
{
"name": "Other Show",
"rating": 8842,
"alternative_name": "Alternate Name 3",
}];
I specifically want to get the alternative_name in a function getAlternateName(). But I want the condition for it to be that it should not be null. How would I go about it?
Edit: For example, for the Jane Doe Show, it has an alternative_name with "Alternate Name 2," while for the John Doe Show, alternative_name is null. When I console.log(getAlternateName()), it would show:
[ { alternative_name: null },
{ alternative_name: 'Alternate Name 2' },
{ alternative_name: 'Alternate Name 3' } ]
However, I just want it to show "Alternate Name 2 and Alternate Name 3, without showing null. How would I go about it?
showsis an array now.