1
1
// Code your orbitCircumference function here:
2
+ function findCircumference ( radius ) {
3
+ let circumference ;
4
+ circumference = ( 2 * Math . PI * radius ) ;
5
+ circumference = Math . round ( circumference )
6
+ return circumference
7
+ }
2
8
3
-
9
+
4
10
// Code your missionDuration function here:
11
+ function findMissionDuration ( orbitsCompleted , orbitRadius , orbitSpeed ) {
12
+ let circumference = findCircumference ( orbitRadius )
13
+ let missionDuration ;
14
+
15
+ orbitPeriod = ( circumference / orbitSpeed )
16
+ missionDuration = ( orbitPeriod * orbitsCompleted )
17
+ missionDuration = missionDuration . toFixed ( 2 )
18
+ return ( `The mission will travel ${ circumference * orbitsCompleted } km around the planet, and it will take ${ missionDuration } hours to complete ` )
19
+
20
+ }
21
+
22
+ console . log ( findMissionDuration ( 5 , 2000 , 28000 ) ) ;
5
23
6
24
7
25
// Copy/paste your selectRandomEntry function here:
8
26
27
+ function selectRandomEntry ( arr ) {
28
+ candidatesSelected = [ ]
29
+ let i ;
30
+
31
+ while ( candidatesSelected . length < 1 ) {
32
+ i = Math . floor ( Math . random ( ) * 6 )
33
+
34
+ if ( ! candidatesSelected . includes ( arr [ i ] ) )
35
+
36
+ candidatesSelected . push ( arr [ i ] )
9
37
38
+ }
39
+ return candidatesSelected
40
+ }
10
41
// Code your oxygenExpended function here:
11
42
43
+ function oxygenExpended ( astronaut ) {
44
+ let o2 ;
45
+ hours = findMissionDuration ( 3 , 2000 , 28000 )
46
+ o2 = astronaut . o2Used ( hours )
47
+ return ( `${ astronaut . name } will perform the spacewalk, which will last ${ hours } and require ${ o2 } kg of oxygen.` )
48
+ }
49
+
12
50
13
51
// Candidate data & crew array.
14
52
let candidateA = {
@@ -55,4 +93,4 @@ let candidateA = {
55
93
} ;
56
94
57
95
let crew = [ candidateA , candidateC , candidateE ] ;
58
-
96
+ console . log ( oxygenExpended ( candidateA ) ) ;
0 commit comments