If you are referring to the different methods included in each crew member’s properties ie. cheerTeam(), agree(), etc., you can just console.log(spaceship.crew.translator.powerFuel()); for an individual crew memeber. There are several ways to loop through the crew members, and invoke each members method. Here’s one way:
for (let crewMember in spaceship.crew) {
//shorten spaceship.crew[crewMember] to ref for convenience
const ref = spaceship.crew[crewMember];
const name = ref.name;
//function to determine which method to invoke
const myFunction = memberName => {
switch (memberName) {
case 'Lily':
return ref.cheerTeam();
case 'Dan':
return ref.agree();
case 'Clementine':
return ref.announce();
case 'Shauna':
return ref.powerFuel();
default:
return 'Hello World!';
}
}
console.log(`${name}: ${myFunction(name)}`);
}
Output:
Lily: You got this!
Dan: I agree, captain!
Clementine: Jets on!
Shauna: The tank is full!