@@ -2,17 +2,84 @@ 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 ( ) {
8
+ return Math . floor ( Math . random ( ) * 10 )
9
+ }
10
+
6
11
} ;
7
12
8
13
let salamander = {
9
14
name : "Lacey" ,
10
15
species : "Axolotl Salamander" ,
11
16
mass : 0.1 ,
12
- age : 5
17
+ age : 5 ,
18
+ astronautID : 2 ,
19
+ move : function ( ) {
20
+ return Math . floor ( Math . random ( ) * 10 )
21
+ }
13
22
} ;
14
23
24
+ let superChimpTwo = {
25
+ name : "Brad " ,
26
+ species : "Chimpanzee" ,
27
+ mass : 11 ,
28
+ age : 6 ,
29
+ astronautID : 3 ,
30
+ move : function ( ) {
31
+ return Math . floor ( Math . random ( ) * 10 )
32
+ }
33
+ } ;
34
+
35
+ let dog = {
36
+ name : "Leroy" ,
37
+ species : "Beagle" ,
38
+ mass : 14 ,
39
+ age : 5 ,
40
+ astronautID : 4 ,
41
+ move : function ( ) {
42
+ return Math . floor ( Math . random ( ) * 10 )
43
+ }
44
+ } ;
45
+
46
+ let lizard = {
47
+ name : "Almina" ,
48
+ species : "Tardigrade" ,
49
+ mass : Math . round ( 0.0000000001 * 100 ) / 10000 ,
50
+ age : 1 ,
51
+ astronautID : 5 ,
52
+ move : function ( ) {
53
+ return Math . floor ( Math . random ( ) * 11 )
54
+ }
55
+ } ;
56
+ let crew = [ superChimpOne , salamander , superChimpTwo , dog , lizard ] ;
57
+
58
+ crew . forEach ( function ( cadet ) {
59
+ console . log ( cadet . name + " is in charge of steps " + cadet . move ( ) + "." ) ;
60
+ } ) ;
61
+ crew . forEach ( function ( animal ) {
62
+ console . log ( `${ animal . name } is a ${ animal . species } . They currently weigh ${ animal . mass } kgs and are ${ animal . age } years old.` )
63
+ } ) ;
64
+
65
+ function fitnessTest ( cadets ) {
66
+ let results = [ ] , numSteps , turns ;
67
+ for ( let i = 0 ; i < cadets . length ; i ++ ) {
68
+ numSteps = 0 ;
69
+ turns = 0 ;
70
+ while ( numSteps < 20 ) {
71
+ numSteps += cadets [ i ] . move ( ) ;
72
+ turns ++ ;
73
+ }
74
+ results . push ( `It took ${ cadets [ i ] . name } , ${ turns } turns to take 20 steps.` )
75
+ }
76
+ return results ;
77
+ }
78
+ let testResults = fitnessTest ( crew ) ;
15
79
80
+ testResults . forEach ( result => {
81
+ console . log ( result ) ;
82
+ } )
16
83
// After you have created the other object literals, add the astronautID property to each one.
17
84
18
85
// Create an array to hold the animal objects.
0 commit comments