You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functioncrewReports(crewMember){//. notation to call
52
+
53
+
console.log(`
54
+
${crewMember.name} is a ${crewMember.species}.
55
+
They are ${crewMember.age} years old and ${crewMember.mass} kilograms.
56
+
Their ID is ${crewMember.astronautID}.`)
57
+
}
58
+
59
+
// crew.forEach(crewReports);
60
+
//for each item in the crew ARRAY run this function in ()
61
+
//aka .length for arrays
62
+
// --- crew.forEach(crewReports) ---
63
+
// go to crew Array [superChimpOne, salamander, fpsCooked, pupper, unKnown]
64
+
// run crewReports on each crewMember of crew Array
65
+
console.log(".........................");
66
+
letcrewSteps=0;
67
+
letcrewTurnCounter=0;//must be inside loop or will not return to 0 for next member of crew
68
+
letcrewTurnsArray=[];
69
+
70
+
functionfitnessTest(crewArray){//crew will be the parameter here
71
+
72
+
for(letcrewMateofcrewArray){//loop goes through each 1 member of the array at a time
73
+
crewSteps=0;
74
+
crewTurnCounter=0;//restarts at 0 when the for loop restarts for the next member
75
+
while(crewSteps<20){//condition for the loop
76
+
77
+
crewSteps+=crewMate.move();//adds the move function ammount together and updates the crewsteps of the 1 member
78
+
79
+
crewTurnCounter++;//counter iteration keeping track of each 1 member turn on their way to 20 steps
80
+
}
81
+
crewTurnsArray.push(crewMate.name+" took "+crewTurnCounter+" turns to take 20 steps.");//push the result of hte crewturncounter into the crew turns array lined up with each member
82
+
}
83
+
// if (crewSteps >= 20) {
84
+
// console.log(`${crewMate.name} took ${crewTurnsArray} turns to take 20 steps.`);
85
+
// }
86
+
returncrewTurnsArray;//need to return functions so that the data can be acessed outside of the function
87
+
}
88
+
89
+
fitnessTest(crew);//use the function fitness test with the crew parameter
90
+
91
+
// console.log(crewTurnsArray);
92
+
93
+
for(letcrewTurnStringofcrewTurnsArray){//for loop that goes through each element in the crewturns array and prints the string element
94
+
console.log(crewTurnString);
95
+
console.log();
96
+
}
15
97
16
-
// After you have created the other object literals, add the astronautID property to each one.
98
+
// X After you have created the other object literals, add the astronautID property to each one.
17
99
18
-
// Add a move method to each animal object
100
+
// X Add a move method to each animal object
19
101
20
-
// Create an array to hold the animal objects.
102
+
// X Create an array to hold the animal objects.
21
103
22
-
// Print out the relevant information about each animal.
104
+
// X Print out the relevant information about each animal.
0 commit comments