11// Code your orbitCircumference function here:
22
3+ let altitude = 2000 ;
4+ let orbitalSpeed = 28000 ;
5+ let orbitsComplete = 5 ;
36
4- // Code your missionDuration function here:
7+ function orbitCircumference ( orbit ) {
8+ return Math . round ( 2 * Math . PI * ( orbit + 6378 ) ) ;
9+ }
510
11+ // Code your missionDuration function here:
12+ function missionDuration ( orbitsComplete , orbitCircumfrence , orbitSpeed ) {
13+ return Math . round ( ( ( orbitsComplete * orbitCircumfrence ) / orbitSpeed ) * 1000 ) / 1000 ;
14+ }
615
716// Copy/paste your selectRandomEntry function here:
8-
17+ function selectRandomEntry ( array ) {
18+ let randomIndex = Math . floor ( Math . random ( ) * array . length ) ;
19+ return array [ randomIndex ] ;
20+ }
921
1022// Code your oxygenExpended function here:
23+ function oxygenExpended ( ) {
24+ let hours = missionDuration ( 3 , orbitCircumference ( altitude ) , orbitalSpeed ) ;
25+ let crewMember = selectRandomEntry ( crew ) ;
26+ let oxygenWeight = Math . round ( crewMember . o2Used ( hours ) * 10000 ) / 10000 ;
27+
28+ return [ crewMember . name , hours , oxygenWeight ] ;
29+ }
1130
1231
1332// Candidate data & crew array.
@@ -54,5 +73,12 @@ let candidateA = {
5473 'astronautID' :890
5574 } ;
5675
57- let crew = [ candidateA , candidateC , candidateE ] ;
58-
76+ let crew = [ candidateA , candidateC , candidateE ] ;
77+
78+ let circumfrence = orbitCircumference ( altitude ) ;
79+ let duration = missionDuration ( orbitsComplete , circumfrence , orbitalSpeed ) ;
80+ console . log ( `The mission will travel ${ orbitsComplete * circumfrence } km around the planet, and it will take ${ duration } hours to complete.` ) ;
81+
82+ let finalResult = oxygenExpended ( ) ;
83+
84+ console . log ( `${ finalResult [ 0 ] } will perform the spacewalk, which will last ${ finalResult [ 1 ] } hours and require ${ finalResult [ 2 ] } kg of oxygen.` )
0 commit comments