You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: booleans-and-conditionals/exercises/part-2.js
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,34 @@ let shuttleSpeed = 15000;
8
8
// 3) Write conditional expressions to satisfy the following safety rules:
9
9
10
10
// a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready".
11
-
11
+
if(crewStatus==true){
12
+
console.log("Crew Ready");
13
+
}else{
14
+
console.log("Crew Not Ready");
15
+
}
12
16
13
17
// 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
+
}elseif(computerStatusCode==400){
21
+
console.log("Success! Computer online.");
22
+
}else{
23
+
console.log("ALERT: Computer offline!");
24
+
}
15
25
16
26
// 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
+
}elseif(computerStatusCode<8000){
30
+
console.log("ALERT: Cannot maintain orbit!");
31
+
}else{
32
+
console.log("Stable speed");
33
+
}
18
34
19
35
// 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result?
}else{console.log("Fuel and engine status pending...");
31
+
}
21
32
// 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.
33
+
letcommandOverride=true
34
+
22
35
23
36
/* 6) b) Code the following if/else check:
24
37
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