Skip to content

Commit 2e7814d

Browse files
shuttle launch
1 parent 9e88293 commit 2e7814d

File tree

3 files changed

+65
-8
lines changed

3 files changed

+65
-8
lines changed
Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,72 @@
11
// Initialize Variables below
22

3-
// add logic below to verify total number of astronauts for shuttle launch does not exceed 7
43

5-
// add logic below to verify all astronauts are ready
64

7-
// add logic below to verify the total mass does not exceed the maximum limit of 850000
5+
let date = "Monday 2019-03-18";
6+
let time = "10:05:34 AM";
7+
let astronautCount = 7;
8+
let astronautStatus = "ready";
9+
let averageAstronautMassKg = 80.7;
10+
let crewMassKg = (astronautCount * averageAstronautMassKg);
11+
let fuelMassKg = 760000;
12+
let shuttleMassKg = 74842.31;
13+
let totalMassKg = crewMassKg + fuelMassKg + shuttleMassKg;
14+
let maximumMassLimit = 850000;
15+
let fuelTempCelsius = -225;
16+
let minimumFuelTemp = -300;
17+
let maximumFuelTemp = -150;
18+
let fuelLevel = "100%";
19+
let weatherStatus = "clear";
20+
let preparedForLiftOff = true;
821

22+
// add logic below to verify total number of astronauts for shuttle launch does not exceed 7
23+
if (astronautCount > 7) {
24+
preparedForLiftOff = false;
25+
console.log("Security alert! Kick " + (astronautCount - 7) + " astronauts off to launch!");
26+
}
27+
// add logic below to verify all astronauts are ready
28+
if (astronautStatus !== "ready") {
29+
preparedForLiftOff = false;
30+
console.log("Somehow, one or more astronaut is not ready????");
31+
}
32+
// add logic below to verify the total mass does not exceed the maximum limit of 850000
33+
if (totalMassKg > maximumMassLimit) {
34+
console.log("Mass exceeds maximum mass limit!");
35+
preparedForLiftOff = false;
36+
}
937
// add logic below to verify the fuel temperature is within the appropriate range of -150 and -300
10-
38+
if (fuelTempCelsius < minimumFuelTemp || fuelTempCelsius > maximumFuelTemp) {
39+
console.log("Fuel temperature is not in range - DO NOT LAUNCH!");
40+
preparedForLiftOff = false;
41+
}
1142
// add logic below to verify the fuel level is at 100%
12-
43+
if (fuelLevel !== "100%") {
44+
preparedForLiftOff = false;
45+
console.log("Please refuel before launch.");
46+
}
1347
// add logic below to verify the weather status is clear
14-
48+
if (weatherStatus !== "clear") {
49+
console.log("Weather is not clear.");
50+
preparedForLiftOff = false;
51+
}
1552
// Verify shuttle launch can proceed based on above conditions
53+
if (!preparedForLiftOff) {
54+
console.log("ABORT MISSION!");
55+
} else {
56+
console.log(`
57+
All systems are a go! Initiating space shuttle launch sequence.
58+
---------------------------------------------------------------
59+
Date: ${date}
60+
Time: ${time}
61+
Astronaut Count: ${astronautCount}
62+
Crew Mass: ${crewMassKg} kg
63+
Fuel Mass: ${fuelMassKg} kg
64+
Shuttle Mass: ${shuttleMassKg} kg
65+
Total Mass: ${totalMassKg} kg
66+
Fuel Temperature: ${fuelTempCelsius} C
67+
Weather Status: ${weatherStatus}
68+
---------------------------------------------------------------
69+
Have a safe trip astronauts!`);
70+
}
71+
72+

errors-and-debugging/exercises/Debugging1stSyntaxError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let launchReady = false;
55
let fuelLevel = 17000;
66

7-
if (fuelLevel >= 20000 {
7+
if (fuelLevel >= 20000) {
88
console.log('Fuel level cleared.');
99
launchReady = true;
1010
} else {

errors-and-debugging/exercises/DebuggingLogicErrors2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (fuelLevel >= 20000) {
1414
launchReady = true;
1515
} else {
1616
console.log('WARNING: Insufficient fuel!');
17-
launchReady = false;
17+
launchReady = false; console.log(launchReady)
1818
}
1919

2020
// if (crewStatus && computerStatus === 'green'){

0 commit comments

Comments
 (0)