I've just started learning about arrays and functions today and would like some help on this following challenge, please. The array is passed in when calling the function.
If there is at least one film where the wonOscar property is false then the function should return false overall. Otherwise, if every film has won an oscar then the function should return true.
What I have so far;
function Winners(films) {
return films.every(element => element === false);
}
Example array of films will look as follows:
Winners([
{
title: "Fake Movie1", wonOscar: true
},
{
title: "Fake Movie2", wonOscar: true
},
{
title: "Fake Movie3", wonOscar: false
}
{
title: "Fake Movie4", wonOscar: true
}
]
);
// should return false
Can you please give me a working example and break it down for me how it works? Many thanks!
films.every(element => element.wonOscar)