Skip to content

Commit 51a92c3

Browse files
committed
if else chain ordered correctly and command override implemented. Parts 1,2, and 3 done.
1 parent 769f690 commit 51a92c3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let engineIndicatorLight = 'red blinking';
2-
let fuelLevel = 21000;
3-
let engineTemperature = 1200;
2+
let fuelLevel = "21000";
3+
let engineTemperature = "1400";
44

55
//5) Implement the following checks using if/else if/else statements:
66

@@ -17,22 +17,29 @@ let engineTemperature = 1200;
1717
//f) Otherwise, print "Fuel and engine status pending..."
1818

1919
// Code 5a - 5f here:
20-
21-
if (fuelLevel > 20000 && engineTemperature <= 2500) {
20+
if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking") {
21+
console.log("ENGINE FAILURE IMMINENT!");
22+
} else if (fuelLevel > 20000 && engineTemperature <= 2500) {
2223
console.log("Full tank. Engines good.");
2324
} else if (fuelLevel > 10000 && engineTemperature <= 2500) {
2425
console.log("Fuel level above 50%. Engines good.");
2526
} else if (fuelLevel > 5000 && engineTemperature <= 2500) {
2627
console.log("Fuel level above 25%. Engines good.");
2728
} else if (fuelLevel <= 5000 || engineTemperature > 2500) {
2829
console.log("Check fuel level. Engines running hot.");
29-
} else if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking") {
30-
console.log("ENGINE FAILURE IMMINENT!");
3130
} else {
3231
console.log("Fuel and engine status pending…");
3332
}
3433

3534
// 6) a) Create the variable commandOverride, and set it to be true or false. If commandOverride is false, then the shuttle should only launch if the fuel and engine check are OK. If commandOverride is true, then the shuttle will launch regardless of the fuel and engine status.
3635

36+
let commandOverride = false;
37+
3738
/* 6) b) Code the following if/else check:
3839
If fuelLevel is above 20000 AND engineIndicatorLight is NOT red blinking OR commandOverride is true print "Cleared to launch!" Else print "Launch scrubbed!" */
40+
41+
if (fuelLevel > 20000 && engineIndicatorLight != "red blinking" || commandOverride) {
42+
console.log("Cleared to launch!");
43+
} else {
44+
console.log("Launch Scrubbed!");
45+
}

0 commit comments

Comments
 (0)