Created
June 25, 2019 21:54
-
-
Save jinwood/a682ef022c4bb47646a984e7650ddc7a to your computer and use it in GitHub Desktop.
Array ting
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
console.log('hello'); | |
const data = [ | |
{ | |
id: 1, | |
country: [ | |
{ id: '5a60626f1d41c80c8d3f8a85' }, | |
{ id: '5a6062661d41c80c8b2f0413' } | |
] | |
}, | |
{ | |
id: 2, | |
country: [ | |
{ id: '5a60626f1d41c80c8d3f8a83' }, | |
{ id: '5a60626f1d41c80c8d3f8a84' } | |
] | |
} | |
]; | |
const result = data.reduce( | |
(arr, elem) => [...arr, ...elem.country.map(({ id }) => id)], | |
[] | |
); | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment