@@ -2,22 +2,83 @@ 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 ( ) * 10 ) }
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 ( ) * 10 ) }
13
17
} ;
14
18
19
+ let chimpanzee = {
20
+ name : "Brad" ,
21
+ species : "Chimpanzee" ,
22
+ mass : 11 ,
23
+ age : 6 ,
24
+ astronautID : 3 ,
25
+ move : function ( ) { return Math . floor ( Math . random ( ) * 10 ) }
26
+ } ;
27
+
28
+ let beagle = {
29
+ name : "Leroy" ,
30
+ species : "Beagle" ,
31
+ mass : 14 ,
32
+ age : 5 ,
33
+ astronautID : 4 ,
34
+ move : function ( ) { return Math . floor ( Math . random ( ) * 10 ) }
35
+ } ;
36
+
37
+ let tardigrade = {
38
+ name : "Almina" ,
39
+ species : "Tardigrade" ,
40
+ mass : 0.0000000001 ,
41
+ age : 1 ,
42
+ astronautID : 5 ,
43
+ move : function ( ) { return Math . floor ( Math . random ( ) * 10 ) }
44
+ } ;
45
+
46
+
47
+ let crew = [ tardigrade , beagle , chimpanzee , salamander , superChimpOne ] ;
48
+
49
+ function crewReports ( animal ) {
50
+ console . log ( animal . name , "is a" , animal . species + ". They are" , animal . age , "years old and" , animal . mass , "kilograms. Their ID is" , animal . astronautID + "." )
51
+ }
52
+
53
+ crewReports ( superChimpOne )
54
+ crewReports ( tardigrade )
55
+
56
+ for ( let i = 0 ; i < crew . length ; i ++ ) {
57
+ crewReports ( crew [ i ] )
58
+ }
59
+
60
+ function fitnessTest ( arr ) {
61
+ let results = [ ] ;
62
+
63
+ for ( let i = 0 ; i < arr . length ; i ++ ) {
64
+ let stepsTaken = 0 ;
65
+ let turnsTaken = 0 ;
66
+ while ( stepsTaken < 20 ) {
67
+ stepsTaken += arr [ i ] . move ( ) ;
68
+ turnsTaken ++
69
+ }
70
+ results . push ( `${ arr [ i ] . name } took ${ turnsTaken } turns to take 20 steps.` ) ;
71
+ }
72
+ return results
73
+ }
74
+ console . log ( fitnessTest ( crew ) )
75
+
15
76
16
- // After you have created the other object literals, add the astronautID property to each one.
77
+ // After you have created the other object literals, add the astronautID property to each one.
17
78
18
- // Add a move method to each animal object
79
+ // Add a move method to each animal object
19
80
20
- // Create an array to hold the animal objects.
81
+ // Create an array to hold the animal objects.
21
82
22
83
// Print out the relevant information about each animal.
23
84
0 commit comments