forked from LaunchCodeEducation/javascript-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectStudio02
More file actions
80 lines (70 loc) · 2.05 KB
/
Copy pathObjectStudio02
File metadata and controls
80 lines (70 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
let distance = 2000;
let speed = 280000;
// Code your orbitCircumference function here:
function orbitCircumference(distance){
let circumference = 2 * Math.PI * distance
return circumference
};
// Code your missionDuration function here:
function missionDuration(orbits,distance,speed){
let time = (orbitCircumference(distance) * orbits) / speed;
time = (Math.round(time * 100)) / 100;
return time
}
console.log(`The mission will travel ${orbitCircumference(distance)}km around the planet, and it will take ${missionDuration(6,distance,speed)} hours to compelte. `)
// Candidate data & crew array.
let candidateA = {
'name':'Gordon Shumway',
'species':'alf',
'mass':90,
'o2Used':function(hrs){return 0.035*hrs},
'astronautID':414
};
let candidateB = {
'name':'Lassie',
'species':'dog',
'mass':19.1,
'o2Used':function(hrs){return 0.030*hrs},
'astronautID':503
};
let candidateC = {
'name':'Jonsey',
'species':'cat',
'mass':3.6,
'o2Used':function(hrs){return 0.022*hrs},
'astronautID':796
};
let candidateD = {
'name':'Paddington',
'species':'bear',
'mass':31.8,
'o2Used':function(hrs){return 0.047*hrs},
'astronautID':291
};
let candidateE = {
'name':'Pete',
'species':'tortoise',
'mass':417,
'o2Used':function(hrs){return 0.010*hrs},
'astronautID':599
};
let candidateF = {
'name':'Hugs',
'species':'ball python',
'mass':2.3,
'o2Used':function(hrs){return 0.018*hrs},
'astronautID':890
};
let crew = [candidateA,candidateC,candidateE];
// Copy/paste your selectRandomEntry function here:
function selectRandomEntry(array){
return Math.floor(Math.random() * array.length);
}
// Code your oxygenExpended function here:
function oxygenExpended(Candidate){
let time = missionDuration(3,distance,speed);
console.log(time);
let o2Used = (Math.round(Candidate.o2Used * time *1000)) / 1000;
return console.log(`${Candidate.name} will perform a spacewalk, which will last ${time} hours and require ${o2Used}kg of oxygen`)
};
console.log(oxygenExpended(selectRandomEntry(crew)));