Skip to content

Commit 935842b

Browse files
committed
finished exercises
1 parent 8d7c834 commit 935842b

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// Declare and initialize the variables for exercise 1 here:
2-
2+
let engineIndicatorLight = ("red blinking");
3+
let spaceSuitsOn = true;
4+
let shuttleCabinReady = true;
5+
let crewStatus = spaceSuitsOn && shuttleCabinReady;
6+
let computerStatusCode = 200;
7+
let shuttleSpeed = 15000;
38
// BEFORE running the code, predict what will be printed to the console by the following statements:
4-
9+
// I predict "engines are off"
510
if (engineIndicatorLight === "green") {
611
console.log("engines have started");
712
} else if (engineIndicatorLight === "green blinking") {

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,34 @@ let computerStatusCode = 200;
66
let shuttleSpeed = 15000;
77

88
// 3) Write conditional expressions to satisfy the following safety rules:
9-
9+
if (crewStatus) {
10+
console.log("Crew Ready");
11+
} else {
12+
console.log("Crew Not Ready")
13+
}
14+
1015
// a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready".
11-
16+
console.log ("Crew Ready");
1217

1318
// 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!"
19+
if (computerStatusCode === 200) {
20+
console.log("Please stand by. Computer is rebooting.");
21+
} else if (computerStatusCode === 400){
22+
console.log ("Success! Computer online.");
23+
} else {
24+
console.log ("ALERT: Computer offline!");
25+
}
1426

1527

1628
// 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-
29+
if (shuttleSpeed > 17500) {
30+
console.log("ALERT: Escape velocity reached!");
31+
} else if (shuttleSpeed < 8000) {
32+
console.log("ALERT: Cannot maintain orbit!");
33+
} else {
34+
console.log("Stable speed")
35+
}
1836

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

21-
console.log(/* "Yes" or "No" */);
39+
console.log("Yes");

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,25 @@ e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndica
1717
f) Otherwise, print "Fuel and engine status pending..." */
1818

1919
// Code 5a - 5f here:
20-
20+
if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === 'red blinking'){
21+
console.log("ENGINE FAILURE IMMINENT!");
22+
} else if (fuelLevel <= 5000 || engineTemperature > 2500){
23+
console.log("Check fuel level. Engines running hot.");
24+
} else if (fuelLevel > 20000 && engineTemperature <= 2500){
25+
console.log("Full tank. Engines good.");
26+
} else if (fuelLevel > 10000 && engineTemperature <= 2500){
27+
console.log("Fuel level above 50%. Engines good.");
28+
} else if (fuelLevel > 5000 && engineTemperature <= 2500){
29+
console.log("Fuel level above 25%. Engines good.");
30+
} else{
31+
console.log("Fuel and engine status pending...");
32+
}
2133
// 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-
34+
let commandOverride = false;
2335
/* 6) b) Code the following if/else check:
2436
If fuelLevel is above 20000 AND engineIndicatorLight is NOT red blinking OR commandOverride is true print "Cleared to launch!" Else print "Launch scrubbed!" */
37+
if (fuelLevel > 20000 && engineIndicatorLight !== 'red blinking'|| commandOverride === true){
38+
console.log("Cleared to launch!");
39+
} else {
40+
console.log("Launch scrubbed!");
41+
}

0 commit comments

Comments
 (0)