I am sorry this is so long, but I am stuck and trying to figure out why I am not getting a value.
This function should return the number of movies in which all the actors that were given as an argument perform in it.
For example: findNumOfMoviesByActors(["Morgan Freeman", "Bob Gunton"]) should return 1, because there is only one movie that both are in (see array below).
it is a big array of movies but this is a snipit:
const movies = [
{"title": "Beetlejuice",
"actors": "Alec Baldwin, Geena Davis, Annie McEnroe, Maurice Page"},
{"title": "The Cotton Club",
"actors": "Richard Gere, Gregory Hines, Diane Lane, Lonette McKee"},
{"title": "The Shawshank Redemption",
"actors": "Tim Robbins, Morgan Freeman, Bob Gunton, William Sadler"},
{"title": "Crocodile Dundee",
"actors": "Paul Hogan, Linda Kozlowski, John Meillon, David Gulpilil"}]
This is my code so far:
const findNumOfMoviesByActors = actors => {
for (i = 0; i < movies.length; i++) {
movies[i].actors = movies[i].actors.split(' ')
}
for (i = 0; i < movies.length; i++) {
let count = 0
if (actors === movies[i].actors) {
count++
}
return count
}
}
const actorCheck = ["Paul Hogan", "Linda Kozlowski"]
let test = findNumOfMoviesByActors(actorCheck)
console.log(test)