Skip to content

Instantly share code, notes, and snippets.

@ibihim
Created September 5, 2017 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibihim/194d2422ef24e0fa425f08c24e416e07 to your computer and use it in GitHub Desktop.
Save ibihim/194d2422ef24e0fa425f08c24e416e07 to your computer and use it in GitHub Desktop.
Power of reduce
const getAuthData = (users) =>
users.reduce((authObj, user) => {
const { roles, organizations, clients } = user;
authObj.userRoles.push(roles.toStirng());
authObj.organizations.push(organizations.toString()) ;
authObj.userClient.push(clients.toSring()) ;
}, { userRoles: [], organizaionts: [], userClients: [] });
@ibihim
Copy link
Author

ibihim commented Sep 5, 2017

const getAuthData = (users) =>
    users.reduce((authObj, user) => {
        const { roles, organizations, clients } = user;
        const { userRoles, organizations, userClient} = authObj;

        userRoles.push(roles.toStirng());
        organizations.push(organizations.toString()) ;
        userClient.push(clients.toSring()) ;
}, { userRoles: [], organizaionts: [], userClients: [] });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment