Skip to content

Commit 77c31f9

Browse files
committed
finished exercises
1 parent 37a763b commit 77c31f9

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

objects-and-math/exercises/ObjectExercises.js

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

812
let salamander = {
913
name: "Lacey",
1014
species: "Axolotl Salamander",
1115
mass: 0.1,
12-
age: 5
16+
age: 5,
17+
astronautID: 3,
18+
move: function () {return Math.floor(Math.random()*11)},
19+
turns:0,
20+
};
21+
22+
let superChimpTwo = {
23+
name: "Brad",
24+
species: "Chimpanzee",
25+
mass: 11,
26+
age: 6,
27+
astronautID:2,
28+
move: function () {return Math.floor(Math.random()*11)},
29+
turns:0,
30+
};
31+
32+
33+
let beagleOne = {
34+
name: "Leroy",
35+
species: "Beagle",
36+
mass: 14,
37+
age: 5,
38+
astronautID: 9,
39+
move: function () {return Math.floor(Math.random()*11)},
40+
turns:0,
1341
};
1442

43+
let tardigradeOne = {
44+
name: "Almina",
45+
species: "Tardigrade",
46+
mass: 0.0000000001,
47+
age: 1,
48+
astronautID: 7,
49+
move: function () {return Math.floor(Math.random()*11)},
50+
turns:0,
51+
};
52+
53+
let crew = [superChimpOne, superChimpTwo, salamander, beagleOne, tardigradeOne];
54+
55+
function crewReports(animal){
56+
console.log(`${animal.name} is a ${animal.species}. They are ${animal.age} years old
57+
and ${animal.mass} kilograms. Their ID is ${animal.astronautID}. `)
58+
}
59+
60+
(crewReports(beagleOne));
61+
62+
function fitnessTest(racer){
63+
64+
raceResults = []
65+
for (i=0; i < racer.length; i++){
66+
steps=0
67+
while (steps < 20){
68+
steps += (racer[i].move())
69+
racer[i].turns ++
70+
}
71+
if (steps >= 20){
72+
raceResults.push(`${racer[i].name} took ${racer[i].turns} turns to take 20 steps. `)
73+
}
74+
75+
76+
}
77+
return raceResults
78+
}
79+
80+
console.log(fitnessTest(crew));
1581

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

0 commit comments

Comments
 (0)