Skip to content

Commit 1a83678

Browse files
committed
if then for shuttle launch
1 parent 41226db commit 1a83678

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

booleans-and-conditionals/exercises/part-1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Declare and initialize the variables for exercise 1 here:
22

3+
let engineIndicatorLight = "green";
4+
35
// BEFORE running the code, predict what will be printed to the console by the following statements:
46

57
if (engineIndicatorLight === "green") {

booleans-and-conditionals/exercises/part-2.js

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,60 @@ let shuttleSpeed = 15000;
88
// 3) Write conditional expressions to satisfy the following safety rules:
99

1010
// a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready".
11-
11+
if(crewStatus){
12+
console.log("Crew Ready");
13+
} else{
14+
console.log("Crew Not Ready");
15+
}
1216

1317
// b) If computerStatusCode is 200, print "Please stand by. Computer is rebooting." Else if computerStatusCode is 400, print "Success! Computer online." Else print "ALERT: Computer offline!"
14-
18+
if(computerStatusCode === 200){
19+
console.log("Please stand by. Computer is rebooting.");
20+
} else if(computerStatusCode === 400){
21+
console.log("Success! Computer online.");
22+
} else{
23+
console.log("ALERT: Computer offline!");
24+
}
1525

1626
// c) If shuttleSpeed is > 17,500, print "ALERT: Escape velocity reached!" Else if shuttleSpeed is < 8000, print "ALERT: Cannot maintain orbit!" Else print "Stable speed".
17-
27+
if(shuttleSpeed > 17500){
28+
console.log("ALERT: Escape velocity reached!");
29+
} else if(shuttleSpeed < 8000){
30+
console.log("ALERT: Cannot maintain orbit!");
31+
} else{
32+
console.log("Stable speed");
33+
}
1834

1935
// 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result?
2036

21-
console.log(/* "Yes" or "No" */);
37+
console.log("yess");
38+
39+
//5. Monitor the shuttle’s fuel status.
40+
//let engineIndicatorLight = !engineIndicatorLight;
41+
let fuelLevel = 18000;
42+
let engineTemperature = 2500;
43+
44+
let commandOverride = true;
45+
46+
47+
48+
if(fuelLevel <= 5000 || engineTemperature >2500){
49+
console.log("Check fuel level. Engines running hot.");
50+
} else if(fuelLevel <= 1000 || engineTemperature >3500 || !engineIndicatorLight){
51+
console.log("ENGINE FAILURE IMMINENT");
52+
} else if(fuelLevel > 20000 && engineTemperature <=2500){
53+
console.log("Full tank. Engines good.");
54+
} else if(fuelLevel > 10000 && engineTemperature <= 2500){
55+
console.log("Fuel level above 50%. Engines good.");
56+
} else if(fuelLevel > 5000 &&engineTemperature <= 2500){
57+
console.log("Fuel level above 25%. Engines good.");
58+
} else{
59+
console.log("Fuel and engine status pending...");
60+
}
61+
62+
63+
if(fuelLevel > 20000 && !engineIndicatorLight || commandOverride === false ){
64+
console.log("Cleard to launch!");
65+
} else{
66+
console.log("Launch scrubbed!");
67+
}

0 commit comments

Comments
 (0)