Last active
August 15, 2019 17:48
-
-
Save tudorilisoi/849433cd6dbbb1859ec74244f1634e9e to your computer and use it in GitHub Desktop.
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 persons =[{ | |
| id: 'aBcDeFgH', | |
| firstName: 'Juan', | |
| lastName: 'Doe', | |
| age: 32 | |
| }, | |
| { | |
| id: 'zYxWvUt', | |
| firstName: 'Alex', | |
| lastName: 'Smith', | |
| age: 24 | |
| }] | |
| const info = [{ | |
| id: 'aBcDeFgH', | |
| occupation: 'architect', | |
| address: { | |
| street: '123 Main St', | |
| city: 'CityTown', | |
| Country: 'USA' | |
| } | |
| }, | |
| { | |
| id: 'zYxWvUt', | |
| occupation: 'receptionist', | |
| address: { | |
| street: '555 Ocean Ave', | |
| city: 'Beach City', | |
| Country: 'USA' | |
| } | |
| }] | |
| const mergeDataStreams = ()=>{ | |
| let retValue = [] | |
| persons.forEach((person)=>{ | |
| console.log(`finding info for: ${person.firstName} ${person.lastName}`) | |
| const personInfo = info.find(item=>item.id===person.id) | |
| const mergedInfo = Object.assign({}, person, personInfo) | |
| //const mergedInfo = {...person, ...personInfo} | |
| retValue.push(mergedInfo) | |
| }) | |
| return retValue | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment