Skip to content

Instantly share code, notes, and snippets.

@embarq
Last active July 6, 2018 15:22
Show Gist options
  • Save embarq/c471f2f925cbcc4a69301c281106ef08 to your computer and use it in GitHub Desktop.
Save embarq/c471f2f925cbcc4a69301c281106ef08 to your computer and use it in GitHub Desktop.
ES6+
const users = [{
"email": "shutchcraft0@un.org",
"id": "186f4765-e2db-4fc0-9b13-0557f922a900",
"ip_address": "38.203.170.215"
}, {
"email": "rrasp1@gov.uk",
"id": "ad79e53c-3d3d-46e2-8d90-c8dd1591d125",
"ip_address": "230.60.100.209"
}, {
"email": "tjepensen2@google.co.uk",
"id": "0f306feb-c3bc-4d28-987f-ea4e185fed7d",
"ip_address": "188.153.240.17"
}, {
"email": "cgood3@alexa.com",
"id": "a2188b5b-8f51-4986-9883-0b2fbc56c82e",
"ip_address": "168.241.245.186"
}, {
"email": "ameiklejohn4@washington.edu",
"id": "b2905ade-573e-4d8d-95ef-ce0e0c77ad8b",
"ip_address": "178.56.93.148"
}, {
"email": "erouchy5@google.nl",
"id": "9c724cb5-e252-428c-a657-148da11d0d77",
"ip_address": "171.206.246.249"
}, {
"email": "vgerrish6@eventbrite.com",
"id": "14db1c2b-34dc-405f-80df-97f1bbc0c017",
"ip_address": "141.159.12.188"
}, {
"email": "pllorente7@quantcast.com",
"id": "60e7a4cd-6199-49ce-b286-33b7f504e8c5",
"ip_address": "243.97.64.242"
}, {
"email": "kwintringham8@meetup.com",
"id": "b817520e-a9fb-40ed-bdf6-07eca526dcc7",
"ip_address": "68.26.89.42"
}, {
"email": "kfrail9@parallels.com",
"id": "85933f7b-7b8b-468d-99f3-a6e032b14482",
"ip_address": "171.22.215.114"
}, {
"email": "smawsona@netscape.com",
"id": "bb59d769-3763-4dc7-bad0-5a7833339233",
"ip_address": "98.239.36.119"
}, {
"email": "hcaldicotb@columbia.edu",
"id": "2a40d703-425b-473a-984e-b4d28f811581",
"ip_address": "117.126.105.48"
}, {
"email": "mluckc@ning.com",
"id": "cf54a1a3-b2bb-4bad-a10e-07543ea50414",
"ip_address": "92.161.226.163"
}, {
"email": "sbenechd@sourceforge.net",
"id": "068edfa4-db2e-45c1-8c86-9744478be563",
"ip_address": "92.77.228.235"
}, {
"email": "jcreasere@deliciousdays.com",
"id": "e6e0b4af-06c6-4271-ac93-29f3254f463f",
"ip_address": "44.219.150.112"
}, {
"email": "bdadswellf@arstechnica.com",
"id": "641b32c0-a8f6-475a-97b2-ed68cdee5c94",
"ip_address": "185.185.209.119"
}, {
"email": "jkidstoneg@google.de",
"id": "9df377de-1170-40fd-8355-70fe83d1275f",
"ip_address": "169.198.174.126"
}, {
"email": "aadkinsh@linkedin.com",
"id": "60b14847-5646-4e7a-9718-ef291998fb22",
"ip_address": "41.175.117.178"
}, {
"email": "dbrunkeri@ocn.ne.jp",
"id": "fd7b446f-812f-4f99-af2a-2be1409e4d47",
"ip_address": "66.171.149.88"
}, {
"email": "tmorgonj@miitbeian.gov.cn",
"id": "c3c4a6fa-a8e9-483c-99a0-5df427e5192d",
"ip_address": "139.133.41.168"
}];
const profiles = [{
"email": "mluckc@ning.com",
"name": "Michèle",
"lang": "Tswana"
}, {
"email": "aadkinsh@linkedin.com",
"name": "André",
"lang": "Kurdish"
}, {
"email": "ameiklejohn4@washington.edu",
"name": "Táng",
"lang": "Moldovan"
}, {
"email": "pllorente7@quantcast.com",
"name": "Dù",
"lang": "Malagasy"
}, {
"email": "jkidstoneg@google.de",
"name": "Zhì",
"lang": "Swahili"
}, {
"email": "aadkinsh@linkedin.com",
"name": "Michèle",
"lang": "Catalan"
}, {
"email": "jcreasere@deliciousdays.com",
"name": "Loïca",
"lang": "Tajik"
}, {
"email": "rrasp1@gov.uk",
"name": "Athéna",
"lang": "Fijian"
}, {
"email": "tmorgonj@miitbeian.gov.cn",
"name": "Marie-ève",
"lang": "New Zealand Sign Language"
}, {
"email": "rrasp1@gov.uk",
"name": "Agnès",
"lang": "Quechua"
}, {
"email": "erouchy5@google.nl",
"name": "Céline",
"lang": "Macedonian"
}, {
"email": "pllorente7@quantcast.com",
"name": "Athéna",
"lang": "Malay"
}, {
"email": "jkidstoneg@google.de",
"name": "Adèle",
"lang": "Croatian"
}, {
"email": "cgood3@alexa.com",
"name": "Véronique",
"lang": "Bosnian"
}, {
"email": "cgood3@alexa.com",
"name": "Björn",
"lang": "Dzongkha"
}, {
"email": "hcaldicotb@columbia.edu",
"name": "Vénus",
"lang": "Finnish"
}, {
"email": "kwintringham8@meetup.com",
"name": "Pénélope",
"lang": "Zulu"
}, {
"email": "jcreasere@deliciousdays.com",
"name": "Daphnée",
"lang": "Catalan"
}, {
"email": "vgerrish6@eventbrite.com",
"name": "Simplifiés",
"lang": "Northern Sotho"
}, {
"email": "erouchy5@google.nl",
"name": "Noémie",
"lang": "New Zealand Sign Language"
}]
const profilesMap = profiles.reduce((accum, item) => {
return {
...accum,
[item.email]: item
}
}, {});
console.log(profilesMap);
users.map(user => {
return {
...user,
...(profilesMap[user.email])
}
});
function login(user, { id }) {
const { credentials } = user;
const { email, password } = credentials;
return email + password + id;
}
login({
id: '',
credentials: {
email: '',
password: '',
},
profile: {
name: ''
}
},
{
id: '',
credentials: {
email: '',
password: '',
},
profile: {
name: ''
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment