Skip to content

Commit b4286ad

Browse files
changes
1 parent f889666 commit b4286ad

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,41 @@ 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!"
14-
18+
if (computerStatusCode === 200) {
19+
console.log("Please stand by. Computer is rebooting.");
20+
} else if (computerStatusCode === 400) {
21+
console.log("Success! Computer online.");
22+
} else {
23+
console.log("ALERT: Computer offline!");
24+
}
1525

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

1935
// 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result?
36+
if (crewStatus && computerStatusCode === 200 && spaceSuitsOn) {
37+
console.log("all systems go");
38+
} else {
39+
console.log("WARNING. Not ready");
40+
}
41+
42+
if (!crewStatus || computerStatusCode !== 200 || !spaceSuitsOn) {
43+
console.log("WARNING. Not ready");
44+
} else {
45+
console.log("all systems go");
46+
}
2047

2148
console.log(/* "Yes" or "No" */);

0 commit comments

Comments
 (0)