11// Code your orbitCircumference function here:
2-
2+ let orbitCircumference = ( r ) => Math . round ( 2 * Math . PI * r )
3+ //console.log(orbitCircumference(2));
34
45// Code your missionDuration function here:
5-
6-
6+ function missionDuration ( orbitsCompleted = 0 , orbitRadius = 2000 , orbitalSpeed = 28000 ) {
7+ let totalOrbDistance = orbitCircumference ( orbitRadius )
8+ let time = totalOrbDistance / orbitalSpeed
9+ time = Math . round ( time * 100 ) / 100 ;
10+ let totalTime = orbitsCompleted * time
11+ console . log ( `The mission will travel ${ totalOrbDistance } km around the planet, and take ${ totalTime } hrs to complete.` )
12+ return orbitsCompleted * time
13+
14+ }
15+ console . log ( missionDuration ( 5 ) )
716// Copy/paste your selectRandomEntry function here:
8-
17+ function selectRandomEntry ( ar , howMany ) {
18+ let selection = [ ] ;
19+ let index ;
20+ while ( selection . length < howMany ) {
21+ index = Math . floor ( Math . random ( ) * ( ar . length ) ) ;
22+ if ( ! ( selection . includes ( ar [ index ] ) ) ) {
23+ selection . push ( ar [ index ] ) ;
24+ }
25+ }
26+ return selection
27+ }
928
1029// Code your oxygenExpended function here:
11-
30+ function oxygenExpended ( obj , orbitCompletion ) {
31+ let spaceWalk = missionDuration ( orbitCompletion ) ;
32+ let oxygen = obj . o2Used ( spaceWalk ) ;
33+ oxygen = Math . round ( oxygen * 1000 ) / 1000
34+ return `${ obj . name } will perform the spacewalk, which will last ${ spaceWalk } hours and require ${ oxygen } kg of oxygen.`
35+ }
1236
1337// Candidate data & crew array.
1438let candidateA = {
@@ -55,4 +79,7 @@ let candidateA = {
5579 } ;
5680
5781 let crew = [ candidateA , candidateC , candidateE ] ;
58-
82+
83+ //console.log(oxygenExpended(candidateA))
84+ console . log ( selectRandomEntry ( crew , 1 ) ) ;
85+ console . log ( oxygenExpended ( candidateA , 3 ) )
0 commit comments