Skip to content

Commit 9518454

Browse files
committed
Exercise: Debugging Syntax
1 parent aca6603 commit 9518454

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

errors-and-debugging/exercises/Debugging1stSyntaxError.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,30 @@
44
let launchReady = false;
55
let fuelLevel = 17000;
66

7-
if (fuelLevel >= 20000 {
7+
if (fuelLevel >= 20000) {
88
console.log('Fuel level cleared.');
99
launchReady = true;
1010
} else {
1111
console.log('WARNING: Insufficient fuel!');
1212
launchReady = false;
13+
}
14+
15+
let crewStatus = true;
16+
let computerStatus = 'green';
17+
18+
if (crewStatus && computerStatus === 'green') {
19+
console.log('Crew & computer cleared.');
20+
launchReady = true;
21+
} else {
22+
console.log('WARNING: Crew or computer not ready!');
23+
launchReady = false;
24+
}
25+
26+
if (launchReady) {
27+
console.log(("10, 9, 8, 7, 6, 5, 4, 3, 2, 1..."));
28+
console.log("Fed parrot...");
29+
console.log("Ignition...");
30+
console.log("Liftoff!");
31+
} else {
32+
console.log("Launch scrubbed.");
1333
}

errors-and-debugging/exercises/DebuggingLogicErrors1.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
// Run this sample code as-is and examine the output.
2-
// Should the shuttle have launched?
3-
// Did it?
4-
// Do not worry about fixing the code yet, we will do that in the next series of exercises.
5-
61
let launchReady = false;
72
let fuelLevel = 17000;
83
let crewStatus = true;
@@ -15,6 +10,7 @@ if (fuelLevel >= 20000) {
1510
console.log('WARNING: Insufficient fuel!');
1611
launchReady = false;
1712
}
13+
console.log(launchReady)
1814

1915
if (crewStatus && computerStatus === 'green'){
2016
console.log('Crew & computer cleared.');
@@ -23,7 +19,7 @@ if (crewStatus && computerStatus === 'green'){
2319
console.log('WARNING: Crew or computer not ready!');
2420
launchReady = false;
2521
}
26-
22+
console.log(launchReady)
2723
if (launchReady) {
2824
console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...');
2925
console.log('Liftoff!');
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
//Run this code first and examine the error message.
2-
//Pay close attention to any line numbers mentioned in the message - these will help locate and repair the mistake in the code.
3-
41
let launchReady = false;
5-
let fuelLevel = 17000;
2+
let fuelLevel = 27000;
63

7-
if (fuellevel >= 20000) {
4+
if (fuelLevel >= 20000) {
85
console.log('Fuel level cleared.');
96
launchReady = true;
107
} else {
118
console.log('WARNING: Insufficient fuel!');
129
launchReady = false;
10+
}
11+
12+
13+
14+
if (fuelLevel >= 20000) {
15+
console.log('Fuel level cleared.');
16+
launchReady = true;
17+
} else {
18+
console.log('WARNING: Insufficient fuel!');
19+
launchReady = false;
20+
}
21+
22+
if (launchReady) {
23+
console.log("10, 9, 8...");
24+
console.log("Fed parrot...");
25+
console.log("6, 5, 4...");
26+
console.log("Ignition...");
27+
console.log("3, 2, 1...");
28+
console.log("Liftoff!");
29+
} else {
30+
console.log("Launch scrubbed.");
1331
}

0 commit comments

Comments
 (0)