Skip to content

Commit 769f690

Browse files
committed
5a-5f done without ordering else if chain
1 parent cd3298a commit 769f690

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@ let engineIndicatorLight = 'red blinking';
22
let fuelLevel = 21000;
33
let engineTemperature = 1200;
44

5-
/* 5) Implement the following checks using if/else if/else statements:
5+
//5) Implement the following checks using if/else if/else statements:
66

7-
a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good."
7+
//a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good."
88

9-
b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good."
9+
//b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good."
1010

11-
c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good."
11+
//c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good."
1212

13-
d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot."
13+
//d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot."
1414

15-
e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!"
15+
//e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!"
1616

17-
f) Otherwise, print "Fuel and engine status pending..." */
17+
//f) Otherwise, print "Fuel and engine status pending..."
1818

1919
// Code 5a - 5f here:
2020

21+
if (fuelLevel > 20000 && engineTemperature <= 2500) {
22+
console.log("Full tank. Engines good.");
23+
} else if (fuelLevel > 10000 && engineTemperature <= 2500) {
24+
console.log("Fuel level above 50%. Engines good.");
25+
} else if (fuelLevel > 5000 && engineTemperature <= 2500) {
26+
console.log("Fuel level above 25%. Engines good.");
27+
} else if (fuelLevel <= 5000 || engineTemperature > 2500) {
28+
console.log("Check fuel level. Engines running hot.");
29+
} else if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking") {
30+
console.log("ENGINE FAILURE IMMINENT!");
31+
} else {
32+
console.log("Fuel and engine status pending…");
33+
}
34+
2135
// 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.
2236

2337
/* 6) b) Code the following if/else check:

0 commit comments

Comments
 (0)