Avoid Nested Map Results
Avoid Nested Map Results
map preserves one output slot for each input item. If each callback returns an array, the final result becomes an array of arrays.
That shape is wrong when the caller needs to search, count, or render individual nested records. flatMap communicates that each source item may expand into multiple output items and that the result should be one level flat.
Your task: Fix getWorkshopParticipants so it returns a flat array of participant names from every workshop. Do not include empty workshop arrays as items in the result.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
Avoid Nested Map Results
map preserves one output slot for each input item. If each callback returns an array, the final result becomes an array of arrays.
That shape is wrong when the caller needs to search, count, or render individual nested records. flatMap communicates that each source item may expand into multiple output items and that the result should be one level flat.
Your task: Fix getWorkshopParticipants so it returns a flat array of participant names from every workshop. Do not include empty workshop arrays as items in the result.