const users = [ { id: '123', name: 'John' }, { id: '345', name: 'Anna' }, { id: '567', name: 'Kate' }, { id: '789', name: 'Jane' } ] function groupNameById(result, user) { return { ...result, [user.id]: user.name } } const groupedUsers = users.reduce(groupNameById, {})