Skip to content

Commit 4021018

Browse files
committed
almost there
1 parent c59271c commit 4021018

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

booleans-and-conditionals/exercises/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// 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:
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;
8+
// BEFORE running the code, predict what will be printed to the console by the following statements: engines are off
49

510
if (engineIndicatorLight === "green") {
611
console.log("engines have started");

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@ 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!"
1418

15-
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+
}
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".
1727

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

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
let engineIndicatorLight = 'red blinking';
2-
let fuelLevel = 21000;
3-
let engineTemperature = 1200;
1+
let engineIndicatorLight = !'red blinking';
2+
let fuelLevel = 18000 ;
3+
let engineTemperature = 2500;
44

55
/* 5) Implement the following checks using if/else if/else statements:
66
@@ -17,6 +17,19 @@ 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+
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 > 1000 && 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+
}
2033

2134
// 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.
2235

0 commit comments

Comments
 (0)