Last active
August 11, 2017 14:55
-
-
Save sangheestyle/c939eb062f58940a87360c742c67248e to your computer and use it in GitHub Desktop.
Practice #1 for Chicago on August 10, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Two inputs | |
const users = [ | |
{ userId: 1, name: 'matt', email: '[email protected]' }, | |
{ userId: 2, name: 'sanghee', email: '[email protected]' }, | |
]; | |
const dashboards = [ | |
{ dashboardId: 1, ownerId: 1, title: 'summer trend 2016' }, | |
{ dashboardId: 2, ownerId: 1, title: 'autumn trend 2016' }, | |
{ dashboardId: 3, ownerId: 1, title: 'shared to me' }, | |
{ dashboardId: 4, ownerId: 2, title: 'spring trend 2015' }, | |
{ dashboardId: 5, ownerId: 2, title: 'shared to me' }, | |
]; | |
// expected output | |
const expected = [ | |
{ owner_name: "matt", title: "summer trend 2016" }, | |
{ owner_name: "matt", title: "autumn trend 2016"}, | |
{ owner_name: "matt", title: "shared to me" }, | |
{ owner_name: "sanghee", title: "spring trend 2015"}, | |
{ owner_name: "sanghee", title: "shared to me"}, | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const original = [ | |
{ owner_name: 'matt', title: 'shared to me' }, | |
{ owner_name: 'matt', title: 'autumn trend 2016' }, | |
{ owner_name: 'sanghee', title: 'shared to me' }, | |
{ owner_name: 'matt', title: 'summer trend 2016' }, | |
{ owner_name: 'sanghee', title: 'spring trend 2015' }, | |
]; | |
const expected = [ | |
{ owner_name: 'matt', title: 'autumn trend 2016' }, | |
{ owner_name: 'matt', title: 'shared to me' }, | |
{ owner_name: 'matt', title: 'summer trend 2016' }, | |
{ owner_name: 'sanghee', title: 'shared to me' }, | |
{ owner_name: 'sanghee', title: 'spring trend 2015' }, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://medium.com/@JeffLombardJr/understanding-foreach-map-filter-and-find-in-javascript-f91da93b9f2c