Trying to filter an array of movies by genre using a function but encountering a TypeError:
TypeError: movie.genres.some is not a function.
(in 'movie.genres.some(function(item){return item.name === genre;})',
'movie.genres.some' is undefined) `
Movie class =>
title: string,
...,
genres: Genre[]
Genre class =>
id: number,
name: string
FilterMovies = (genre: string) => {
let fmovies: Movie[] = this.state.movies.filter((movie) => {
let data = movie.genres.some((item) => item.name === genre);
return data;
});
Seeking guidance on whether the functions are being used correctly, any help would be greatly appreciated!
edit: example of movie object can be viewed here: https://i.sstatic.net/C9q7o.png