I have a long if statement where I check different combinations of possibilities. Here is the current code I have:
for (let i = 0; i < movies.length; i++) {
if (taste[0] == movies[i].genres[0].name ||
taste[0] == movies[i].genres[1].name ||
taste[0] == movies[i].genres[2].name ||
taste[1] == movies[i].genres[0].name ||
taste[1] == movies[i].genres[1].name ||
taste[1] == movies[i].genres[2].name ||
taste[2] == movies[i].genres[0].name ||
taste[2] == movies[i].genres[1].name ||
taste[2] == movies[i].genres[2].name
) {
moviesForUser.push(movies[i].original_title);
}
}
My Problem: Some of the movies hava different amounts of genres. That means that in some cases I run into an out of bound exception. How can I check all the possible combination options under consideration of the array length?
Aucun commentaire:
Enregistrer un commentaire