Nested Objects
Tue Oct 05 2021 14:55:28 GMT+0000 (Coordinated Universal Time)
Saved by @ianvalentino #javascript #objects
Exercise Nested Objects 1. Create a variable capFave and assign the captain‘s favorite food (the element in the 0th index of her 'favorite foods' array) to it. Make sure to use bracket and dot notation to get the value of the food through nested access (don’t just copy the value into the variable!) 2. Right now the passengers property has a value of null. Instead, assign as its value an array of objects. These objects should represent the spaceship‘s passengers as individual objects. Make at least one passenger object in the array that has at least one key-value pair on it. 3. Create a variable firstPassenger and assign the first passenger as its value (the element in the 0th index of the spaceship.passengers array you just made). Make sure to use bracket and dot notation to get the passenger object through nested access (don’t just copy the object into the variable!)
https://www.codecademy.com/courses/introduction-to-javascript/lessons/objects/exercises/nested-objects
Comments