Welcome to the Treehouse Community
Looking to learn something new?
Steven Vallarsa10,842 Points
I came up with this solution and generated the same result
I solved this on my own and came up with this solution that generated the same result. I reduced the array into an array of objects before mapping the book titles into a new array.
const results = users .reduce((arr, item) => [...arr, ...item.favoriteBooks], ) .map(arr => arr.title);
Joel's solution is
const books = users .map(item => item.favoriteBooks.map(book => book.title)) .reduce((arr, item) => [...arr, ...item]);
Is one inherently better than the other?
They are both similar so I wouldnt say one is better