@@ -2,21 +2,76 @@ 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 ) }
68} ;
79
810let salamander = {
911 name : "Lacey" ,
1012 species : "Axolotl Salamander" ,
1113 mass : 0.1 ,
12- age : 5
14+ age : 5 ,
15+ astronautID : 2 ,
16+ move : function ( ) { return Math . floor ( Math . random ( ) * 11 ) }
1317} ;
1418
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+ } ;
27+
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+ } ;
36+
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+ } ;
45+
46+ let crew = [ superChimpOne , superChimpTwo , salamander , dog , waterBear ] ;
47+
1548
1649// After you have created the other object literals, add the astronautID property to each one.
1750
1851// Create an array to hold the animal objects.
1952
2053// Print out the relevant information about each animal.
2154
22- // Start an animal race!
55+ let crewReports = function ( animal ) {
56+ return `${ animal . name } is a ${ animal . species } . They are ${ animal . age } years old and ${ animal . mass } kilograms. Their ID is ${ animal . astronautID } .`
57+ }
58+ console . log ( crewReports ( dog ) ) ;
59+ console . log ( crewReports ( waterBear ) ) ;
60+
61+ // Start an animal race!
62+
63+ function fitnessTest ( arr ) {
64+ let results = [ ] , numSteps , turns ;
65+ for ( let i = 0 ; i < arr . length ; i ++ ) {
66+ numSteps = 0 ;
67+ turns = 0 ;
68+ while ( numSteps < 20 ) {
69+ numSteps += arr [ i ] . move ( ) ;
70+ turns ++ ;
71+ }
72+ results . push ( `${ arr [ i ] . name } took ${ turns } turns to take 20 steps.` ) ;
73+ }
74+ return results ;
75+ }
76+
77+ console . log ( fitnessTest ( crew ) ) ;
0 commit comments