Skip to main content

Practice · 2 of 2

Index a List with Map

CHALLENGE
Difficulty: intermediate+25 XP

Write indexById(users) that returns a Map from each user's id to the user object, and lookup(index, id) that returns the user or null when absent. Then write groupByRole(users) returning a Map from role to an array of users with that role.

Back to lesson: Practice: Choosing Structures — Practice