Skip to content

Commit 2845d9e

Browse files
committed
booleans and conditionals exercises starter-code
1 parent e0f20f8 commit 2845d9e

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

booleans-and-conditionals/part-1.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Declare and initialize the variables for exercise 1 here:
2+
3+
// BEFORE running the code, predict what will be printed to the console by the following statements:
4+
5+
if (engineIndicatorLight === "green") {
6+
console.log("engines have started");
7+
} else if (engineIndicatorLight === "green blinking") {
8+
console.log("engines are preparing to start");
9+
} else {
10+
console.log("engines are off");
11+
}

booleans-and-conditionals/part-2.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let engineIndicatorLight = "red blinking";
2+
let spaceSuitsOn = true;
3+
let shuttleCabinReady = true;
4+
let crewStatus = spaceSuitsOn && shuttleCabinReady;
5+
let computerStatusCode = 200;
6+
let shuttleSpeed = 15000;
7+
8+
// 3) Write conditional expressions to satisfy the following safety rules:
9+
10+
// a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready".
11+
12+
13+
// 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+
15+
16+
// 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+
18+
19+
// 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result?
20+
21+
console.log(/* "Yes" or "No" */);

booleans-and-conditionals/part-3.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let engineIndicatorLight = 'red blinking';
2+
let fuelLevel = 21000;
3+
let engineTemperature = 1200;
4+
5+
/* 5) Implement the following checks using if/else if/else statements:
6+
7+
a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good."
8+
9+
b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good."
10+
11+
c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good."
12+
13+
d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot."
14+
15+
e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!"
16+
17+
f) Otherwise, print "Fuel and engine status pending..." */
18+
19+
// Code 5a - 5f here:
20+
21+
// 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.
22+
23+
/* 6) b) Code the following if/else check:
24+
If fuelLevel is above 20000 AND engineIndicatorLight is NOT red blinking OR commandOverride is true print "Cleared to launch!" Else print "Launch scrubbed!" */

0 commit comments

Comments
 (0)