@@ -2,23 +2,70 @@ let superChimpOne = {
2
2
name : "Chad" ,
3
3
species : "Chimpanzee" ,
4
4
mass : 9 ,
5
- age : 6
5
+ age : 6 ,
6
+ astronautID : 1 ,
7
+ move : function ( ) { return Math . floor ( Math . random ( ) * 11 ) }
6
8
} ;
7
9
8
10
let salamander = {
9
11
name : "Lacey" ,
10
12
species : "Axolotl Salamander" ,
11
13
mass : 0.1 ,
12
- age : 5
14
+ age : 5 ,
15
+ astronautID : 2 ,
16
+ move : function ( ) { return Math . floor ( Math . random ( ) * 11 ) }
13
17
} ;
14
18
19
+ let superChimpTwo = {
20
+ name : "Brad" ,
21
+ species : "Chimpanzee" ,
22
+ mass : 11 ,
23
+ age : 6 ,
24
+ astronautID : 3 ,
25
+ move : function ( ) { return Math . floor ( Math . random ( ) * 11 ) }
26
+ } ;
15
27
16
- // After you have created the other object literals, add the astronautID property to each one.
17
-
18
- // Add a move method to each animal object
28
+ let dog = {
29
+ name : "Leroy" ,
30
+ species : "Beagle" ,
31
+ mass : 14 ,
32
+ age : 5 ,
33
+ astronautID : 4 ,
34
+ move : function ( ) { return Math . floor ( Math . random ( ) * 11 ) }
35
+ } ;
19
36
20
- // Create an array to hold the animal objects.
37
+ let waterBear = {
38
+ name : "Almina" ,
39
+ species : "Tardigrade" ,
40
+ mass : "0.0000000001" ,
41
+ age : 1 ,
42
+ astronautID : 5 ,
43
+ move : function ( ) { return Math . floor ( Math . random ( ) * 11 ) }
44
+ } ;
21
45
22
- // Print out the relevant information about each animal.
46
+ let crew = [ superChimpOne , superChimpTwo , salamander , dog , waterBear ] ;
23
47
48
+ console . log ( `${ superChimpOne . name } is a ${ superChimpOne . species } . They are ${ superChimpOne . age } years old and ${ superChimpOne . mass } kilograms.` ) ;
49
+ console . log ( `${ superChimpTwo . name } is a ${ superChimpTwo . species } . They are ${ superChimpTwo . age } years old and ${ superChimpTwo . mass } kilograms.` ) ;
50
+ console . log ( `${ salamander . name } is a ${ salamander . species } . They are ${ salamander . age } years old and ${ salamander . mass } kilograms.` ) ;
51
+ console . log ( `${ dog . name } is a ${ dog . species } . They are ${ dog . age } years old and ${ dog . mass } kilograms.` ) ;
52
+ console . log ( `${ waterBear . name } is a ${ waterBear . species } . They are ${ waterBear . age } years old and ${ waterBear . mass } kilograms.` ) ;
53
+ console . log ( "\n" ) ;
24
54
// Start an animal race!
55
+
56
+
57
+ function fitnessTest ( testingAstronauts ) {
58
+ let results = [ ] , numSteps , turns ;
59
+ for ( let i = 0 ; i < testingAstronauts . length ; i ++ ) {
60
+ numSteps = 0 ;
61
+ turns = 0 ;
62
+ while ( numSteps < 20 ) {
63
+ numSteps += testingAstronauts [ i ] . move ( ) ;
64
+ turns ++ ;
65
+ }
66
+ results . push ( `${ testingAstronauts [ i ] . name } took ${ turns } turns to take 20 steps.` ) ;
67
+ }
68
+ return results ;
69
+ }
70
+
71
+ console . log ( fitnessTest ( crew ) ) ;
0 commit comments