Skip to content

Commit c116591

Browse files
authored
Merge pull request #3 from SyedAlvi22/Conditions-homework
Conditions homework
2 parents c181a7c + fdb8256 commit c116591

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,46 @@ let shuttleSpeed = 15000;
99

1010
// a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready".
1111

12+
if (crewStatus) {
13+
console.log("Crew Ready");
14+
} else {
15+
console.log("Crew Not Ready");
16+
}
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!"
1419

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

30+
if (shuttleSpeed > 17500) {
31+
console.log("ALERT: Escape velocity reached!");
32+
} else if (shuttleSpeed < 8000) {
33+
console.log("ALERT: Cannot maintain orbit!");
34+
} else {
35+
console.log("Stable speed.");
36+
}
37+
1838

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

21-
console.log(/* "Yes" or "No" */);
41+
if (crewStatus && computerStatusCode === 200 && spaceSuitsOn) {
42+
console.log("all systems go");
43+
} else {
44+
console.log("WARNING. Not ready");
45+
}
46+
47+
if (!crewStatus || computerStatusCode !== 200 || !spaceSuitsOn) {
48+
console.log("WARNING. Not ready");
49+
} else {
50+
console.log("all systems go");
51+
}
52+
53+
54+
console.log("Yes");

0 commit comments

Comments
 (0)