Not that it matters, but for the sake of offering an alternative solution I'd probably lean more towards Object.fromEntries than reduce.
Object.fromEntries
reduce
Object.fromEntries(users.map(u => [ u.id, u ]))
totally matters and I wish I could heart this twice -- I've never seen Object.fromEntries!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Not that it matters, but for the sake of offering an alternative solution I'd probably lean more towards
Object.fromEntries
thanreduce
.totally matters and I wish I could heart this twice -- I've never seen
Object.fromEntries
!