1
1
// Declare and initialize the variables for exercise 1 here:
2
+ let engineIndicatorLight = "green blinking" ;
3
+ let spaceSuitsOn = true ;
4
+ let shuttleCabinReady = true ;
5
+ let crewStatus = spaceSuitsOn && shuttleCabinReady ;
6
+ let computerStatusCode = 200 ;
7
+ let shuttleSpeed = 15000 ;
2
8
9
+ let fuelLevel = 20000
10
+ let engineTemperature = 2500
3
11
// BEFORE running the code, predict what will be printed to the console by the following statements:
4
-
12
+ //2.
5
13
if ( engineIndicatorLight === "green" ) {
6
14
console . log ( "engines have started" ) ;
7
15
} else if ( engineIndicatorLight === "green blinking" ) {
8
16
console . log ( "engines are preparing to start" ) ;
9
17
} else {
10
18
console . log ( "engines are off" ) ;
11
19
}
20
+ //3.
21
+ if ( crewStatus = true ) {
22
+ console . log ( "Crew Ready" ) ;
23
+ } else {
24
+ console . log ( "Crew Not Ready" ) ;
25
+ }
26
+
27
+ if ( computerStatusCode === 200 ) {
28
+ console . log ( "Please stand by. Computer is rebooting" ) ;
29
+ } else if ( shuttleSpeed === 400 ) {
30
+ console . log ( "Success! Computer online" ) ;
31
+ } else {
32
+ console . log ( "ALERT: Computer Offline." ) ;
33
+ }
34
+
35
+ if ( shuttleSpeed > 17500 ) {
36
+ console . log ( "ALERT: Escape velocity reached!" ) ;
37
+ } else if ( shuttleSpeed < 8000 ) {
38
+ console . log ( "ALERT: Cannot maintain orbit!" ) ;
39
+ } else {
40
+ console . log ( "Stable speed" ) ;
41
+ }
42
+ //4. Predict: Yes, both outputs will be the same. See below:
43
+ if ( crewStatus && computerStatusCode === 200 && spaceSuitsOn ) {
44
+ console . log ( "all systems go" ) ;
45
+ } else {
46
+ console . log ( "WARNING. Not ready" ) ;
47
+ }
48
+
49
+ if ( ! crewStatus || computerStatusCode !== 200 || ! spaceSuitsOn ) {
50
+ console . log ( "WARNING. Not ready" ) ;
51
+ } else {
52
+ console . log ( "all systems go" ) ;
53
+ }
54
+
55
+ //5.Monitor Status
56
+ if ( fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking" ) {
57
+ console . log ( "ENGINE FAILURE IMMINENT!" ) ;
58
+ } else if ( fuelLevel <= 5000 || engineTemperature > 2500 ) {
59
+ console . log ( "Check fuel level. Engines running hot." ) ;
60
+ } else if ( fuelLevel > 20000 && engineTemperature <= 2500 ) {
61
+ console . log ( "Full tank. Engines good." ) ;
62
+ } else if ( fuelLevel > 10000 && engineTemperature <= 2500 ) {
63
+ console . log ( "Fuel level above 50%. Engines good." ) ;
64
+ } else if ( fuelLevel > 5000 && engineTemperature <= 2500 ) {
65
+ console . log ( "Fuel level above 25%. Engines good." ) ;
66
+ } else {
67
+ console . log ( "Fuel and engine status pending..." ) ;
68
+ }
69
+
70
+ //6. Final bit of fun
71
+
72
+ commandOverride = true
73
+
74
+ if ( fuelLevel > 20000 && ! engineIndicatorLight || ! commandOverride ) {
75
+ console . log ( "Cleared to launch!" ) ;
76
+ } else {
77
+ console . log ( "Launch scrubbed!" ) ;
78
+ }
0 commit comments