Skip to content

Commit 90f4739

Browse files
done
1 parent 773b9fa commit 90f4739

File tree

5 files changed

+124
-53
lines changed

5 files changed

+124
-53
lines changed
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
// Declare and assign the variables below
2+
let shuttleName = 'Determination';
3+
let shuttleSpeedMph = 17500;
4+
let distanceToMarsKm = 225000000;
5+
let distanceToMoonKm = 38400;
6+
const milesPerKm = 0.621;
27

38
// Use console.log to print the 'typeof' each variable. Print one item per line.
4-
9+
console.log ( typeof shuttleName);
10+
console.log ( typeof shuttleSpeedMph);
11+
console.log ( typeof distanceToMarsKm);
12+
console.log ( typeof distanceToMoonKm);
13+
console.log ( typeof milesPerKm);
514
// Calculate a space mission below
6-
15+
let milesToMars = kilometersToMars * milesPerKilometer;
16+
let hoursToMars = milesToMars / shuttleSpeedMph;
17+
let daysToMars = hoursToMars / 24;
718
// Print the results of the space mission calculations below
8-
19+
console.log(shuttleName + " will take " + daysToMars + " days to reach the Moon.");
920
// Calculate a trip to the moon below
21+
let milesToMoon = kilometersToMoon * milesPerKilometer;
22+
let hoursToMoon = milesToMoon / shuttleSpeedMph;
23+
let daysToMoon = hoursToMoon / 24;
24+
25+
// Print the results of the trip to the moon belows
1026

11-
// Print the results of the trip to the moon below
27+
console.log(shuttleName + " will take " + daysToMoon + " days to reach the Moon.");

more-on-functions/studio/part-one-find-minimum-value.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3];
66
let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0];
77

88
//Using one of the test arrays as the argument, call your function inside the console.log statement below.
9+
let = minValue;czSqq2se
10+
function findMinValue (arr)
11+
{
912

13+
}
1014
console.log(/* your code here */);

objects-and-math/studio/ObjectsStudio01.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
// Code your selectRandomEntry function here:
22

3+
function selectRandomEntry(array){
4+
let randomIndex = Math.floor(Math.random() * array.length);
5+
return array[randomIndex];
6+
}
37

4-
// Code your buildCrewArray function here:
8+
function getThreeIds(array) {
9+
let newArray = [];
10+
while (newArray.length < 3) {
11+
let selectedItem = selectRandomEntry(array);
12+
if (newArray.includes(selectedItem) === false) {
13+
newArray.push(selectedItem);
14+
}
15+
}
16+
return newArray;
17+
}
518

19+
// Code your buildCrewArray function here:
20+
function buildCrewArray(array1, array2){
21+
let crew = [];
22+
for (let candidate in array2) {
23+
if (array1.includes(array2[candidate].astronautID) === true) {
24+
crew.push(array2[candidate].name);
25+
}
26+
}
27+
return crew;
28+
}
629

730
let idNumbers = [291, 414, 503, 599, 796, 890];
831

@@ -53,3 +76,6 @@ let candidateF = {
5376
let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF];
5477

5578
// Code your template literal and console.log statements:
79+
80+
let selectedCrew = buildCrewArray(getThreeIds(idNumbers), animals);
81+
console.log(`${selectedCrew[0]}, ${selectedCrew[1]}, and ${selectedCrew[2]} are going to space!`)

objects-and-math/studio/ObjectsStudio02.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
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.`)

objects-and-math/studio/ObjectsStudio03.js

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,46 @@
88
// Feel free to add, remove, or switch crew members as you see fit.
99

1010
let candidateA = {
11-
'name':'Gordon Shumway',
12-
'species':'alf',
13-
'mass':90,
14-
'o2Used':function(hrs){return 0.035*hrs},
15-
'astronautID':414
16-
};
17-
let candidateB = {
18-
'name':'Lassie',
19-
'species':'dog',
20-
'mass':19.1,
21-
'o2Used':function(hrs){return 0.030*hrs},
22-
'astronautID':503
23-
};
24-
let candidateC = {
25-
'name':'Jonsey',
26-
'species':'cat',
27-
'mass':3.6,
28-
'o2Used':function(hrs){return 0.022*hrs},
29-
'astronautID':796
30-
};
31-
let candidateD = {
32-
'name':'Paddington',
33-
'species':'bear',
34-
'mass':31.8,
35-
'o2Used':function(hrs){return 0.047*hrs},
36-
'astronautID':291
37-
};
38-
let candidateE = {
39-
'name':'Pete',
40-
'species':'tortoise',
41-
'mass':417,
42-
'o2Used':function(hrs){return 0.010*hrs},
43-
'astronautID':599
44-
};
45-
let candidateF = {
46-
'name':'Hugs',
47-
'species':'ball python',
48-
'mass':2.3,
49-
'o2Used':function(hrs){return 0.018*hrs},
50-
'astronautID':890
51-
};
52-
53-
let crew = [candidateB,candidateD,candidateF];
54-
11+
'name':'Gordon Shumway',
12+
'species':'alf',
13+
'mass':90,
14+
'o2Used':function(hrs){return 0.035*hrs},
15+
'astronautID':414
16+
};
17+
let candidateB = {
18+
'name':'Lassie',
19+
'species':'dog',
20+
'mass':19.1,
21+
'o2Used':function(hrs){return 0.030*hrs},
22+
'astronautID':503
23+
};
24+
let candidateC = {
25+
'name':'Jonsey',
26+
'species':'cat',
27+
'mass':3.6,
28+
'o2Used':function(hrs){return 0.022*hrs},
29+
'astronautID':796
30+
};
31+
let candidateD = {
32+
'name':'Paddington',
33+
'species':'bear',
34+
'mass':31.8,
35+
'o2Used':function(hrs){return 0.047*hrs},
36+
'astronautID':291
37+
};
38+
let candidateE = {
39+
'name':'Pete',
40+
'species':'tortoise',
41+
'mass':417,
42+
'o2Used':function(hrs){return 0.010*hrs},
43+
'astronautID':599
44+
};
45+
let candidateF = {
46+
'name':'Hugs',
47+
'species':'ball python',
48+
'mass':2.3,
49+
'o2Used':function(hrs){return 0.018*hrs},
50+
'astronautID':890
51+
};
52+
53+
let crew = [candidateB,candidateD,candidateF];

0 commit comments

Comments
 (0)