Skip to content

Commit 0d9a557

Browse files
committed
2/3
1 parent afe0098 commit 0d9a557

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

objects-and-math/exercises/ObjectExercises.js

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,77 @@ let superChimpOne = {
22
name: "Chad",
33
species: "Chimpanzee",
44
mass: 9,
5-
age: 6
5+
age: 6,
6+
astronautID : 0 ,
7+
move : function() {return Math.floor(Math.random()*11)}
68
};
79

810
let salamander = {
911
name: "Lacey",
1012
species: "Axolotl Salamander",
1113
mass: 0.1,
12-
age: 5
14+
age: 5,
15+
astronautID : 1,
16+
move : function() {return Math.floor(Math.random()*11)}
1317
};
1418

19+
let superChimpTwo = {
20+
name: "Brad",
21+
species : "Chimpanzee",
22+
mass : 14,
23+
age: 6,
24+
astronautID :2,
25+
move : function() {return Math.floor(Math.random()*11)}
26+
};
27+
let dog = {
28+
name: "Leroy",
29+
species:"Beagle",
30+
mass: 14,
31+
age: 5,
32+
astronautID: 3,
33+
move : function() {return Math.floor(Math.random()*11)}
34+
};
35+
let waterBear= {
36+
name: "Almina",
37+
species:"Tardigrade",
38+
mass: .0000000001,
39+
age: 1,
40+
astronautID:4,
41+
move : function() {return Math.floor(Math.random()*11)}
42+
43+
};
44+
45+
let crew = [superChimpOne, superChimpTwo, salamander, dog, waterBear];
46+
47+
function crewReports(animal){
48+
49+
console.log(animal.name , "is a",animal.species,". They are ",animal.age,"years old. and ",(animal.mass),"kilograms. Their ID is ",animal.astronautID,".")}
50+
51+
console.log(crewReports(waterBear));
52+
53+
54+
function fitnessTest(animal){
55+
let results = [], numSteps, turns;
56+
for (let i = 0; i < candidates.length; i++){
57+
numSteps = 0;
58+
turns = 0;
59+
while(numSteps < 20){
60+
numSteps += candidates[i].move();
61+
turns++;
62+
}
63+
results.push(`${candidates[i].name} took ${turns} turns to take 20 steps.`);
64+
}
65+
return results;
66+
}
67+
68+
69+
70+
71+
72+
73+
74+
75+
1576

1677
// After you have created the other object literals, add the astronautID property to each one.
1778

0 commit comments

Comments
 (0)