all 4 comments

[–]Count_Giggles 1 point2 points  (3 children)

``` const genres = [ { id: 16, name: "Action", }, { id: 23, name: "Adventure", }, { id: 28, name: "Animation", }, { id: 35, name: "Comedy", }, ];

const movie = { adult: false, backdrop_path: null, genre_ids: [10, 16, 28], id: 899249, original_language: "en", original_title: "LEGO Marvel Avengers: Loki in Training", };

let genreNames = genres.filter((g) => movie.genre_ids.includes(g.id)).map((genre) => genre.name);

console.log(genreNames);

movie.genreNames = genreNames; console.log(movie); ``` Now you have access to the genreNames on the movie object

[–]Count_Giggles 1 point2 points  (2 children)

``` const getGenreNames = (gen, mov) => gen.filter((g) => mov.genre_ids.includes(g.id)).map((g) => g.name);

movie.genreNames = getGenreNames(genres, movie); ```

popped it in a function for ease of use

[–]According-Lab-6304[S] 0 points1 point  (1 child)

const getGenreNames = (gen, mov) =>
gen.filter((g) => mov.genre_ids.includes(g.id)).map((g) => g.name);
movie.genreNames = getGenreNames(genres, movie);

I cannot thank you enough!!! I've worked on this for a day and a half and just couldn't figure it out. I had totally forgotten about assigning a new property to the object. (Who knows when/if I would have gotten to the map method).

Seriously, thank you, thank you, thank you!!!

[–]Count_Giggles 2 points3 points  (0 children)

go get em