Advertisement
makispaiktis

Codecademy - 25th Course (Example in Iteration of Objects)

Dec 20th, 2019 (edited)
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let spaceship = {
  2.     crew: {
  3.     captain: {
  4.         name: 'Lily',
  5.         degree: 'Computer Engineering',
  6.         cheerTeam() { console.log('You got this!') }
  7.         },
  8.     'chief officer': {
  9.         name: 'Dan',
  10.         degree: 'Aerospace Engineering',
  11.         agree() { console.log('I agree, captain!') }
  12.         },
  13.     medic: {
  14.         name: 'Clementine',
  15.         degree: 'Physics',
  16.         announce() { console.log(`Jets on!`) } },
  17.     translator: {
  18.         name: 'Shauna',
  19.         degree: 'Conservation Science',
  20.         powerFuel() { console.log('The tank is full!') }
  21.         }
  22.     }
  23. };
  24.  
  25. // Write your code below
  26. for(let crewMember in spaceship.crew){
  27.   console.log(crewMember + ": " + spaceship.crew[crewMember].name);
  28. }
  29.  
  30. for(let crewMember in spaceship.crew){
  31.   console.log(spaceship.crew[crewMember].name + ": " + spaceship.crew[crewMember].degree);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement