Deviopath › JavaScript

Lookup by ID

Easy · Objects

Write a function indexById that turns an array of objects into a lookup object. Each key is an item's id and each value is the whole item.

If two items share the same id, the later one wins.

Next: Mask a Card Number