I want to collect all the movie id's where in rating is above 3 from the below array
let movies = [
{'name': 'Actions', 'movies': [{'id': 1, 'rating': 2},
{'id': 2, 'rating': 1},
{'id': 3, 'rating': 4}]},
{'name': 'Comedy', 'movies': [{'id': 4, 'rating': 3},
{'id': 5, 'rating': 4},
{'id': 6, 'rating': 5}]},
{'name': 'Sci-fi', 'movies': [{'id': 7, 'rating': 1},
{'id': 8, 'rating': 5},
{'id': 9, 'rating': 2}]}
];
I'm getting the id's with rating above 3 from below code
let res = movies
.map( m => m.movies
.filter( f => f.rating > 3 )
)
.flat();
console.log(res);
output
[[object Object] {
id: 3,
rating: 4
}, [object Object] {
id: 5,
rating: 4
}, [object Object] {
id: 6,
rating: 5
}, [object Object] {
id: 8,
rating: 5
}]
How can i get rid of [object Object] and rating from my output and get only flatted id's array?