Created
June 4, 2018 12:01
-
-
Save nathan-lapinski/0027ef89f5b3f6e718c06ff7e22c6a87 to your computer and use it in GitHub Desktop.
Nested Arrays
This file contains 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 gameData = [ | |
{ | |
title: 'Mega Man 2', | |
bosses: [ | |
{ | |
name: 'Bubble Man', | |
weapon: 'Bubble Beam' | |
}, | |
{ | |
name: 'Metal Man', | |
weapon: 'Metal Blade' | |
}] | |
}, | |
{ | |
title: 'Mega Man 3', | |
bosses: [ | |
{ | |
name: 'Gemini Man', | |
weapon: 'Gemini Laser' | |
}, | |
{ | |
name: 'Top Man', | |
weapon: 'Top Spin' | |
}] | |
} | |
]; | |
// return an array of all bosses | |
const bossesArray = gameData.map(game => { | |
return game.bosses; | |
}); | |
// uh oh, those are nested arrays! | |
// [[{},{}],[{},{}]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment