Skip to content

Commit 767e932

Browse files
brians debugging exercise
1 parent 84331c4 commit 767e932

6 files changed

+18
-43
lines changed

errors-and-debugging/exercises/Debugging1stSyntaxError.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
//Run this code first and examine the error message.
2-
//Fix the syntax error then run the code again to check your work.
3-
41
let launchReady = false;
52
let fuelLevel = 17000;
63

7-
if (fuelLevel >= 20000 {
4+
if (fuelLevel >= 20000) {
85
console.log('Fuel level cleared.');
96
launchReady = true;
107
} else {
Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
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;
7-
let fuelLevel = 17000;
8-
let crewStatus = true;
9-
let computerStatus = 'green';
2+
let fuelLevel = 20000;
103

114
if (fuelLevel >= 20000) {
125
console.log('Fuel level cleared.');
136
launchReady = true;
147
} else {
158
console.log('WARNING: Insufficient fuel!');
169
launchReady = false;
17-
}
18-
19-
if (crewStatus && computerStatus === 'green'){
20-
console.log('Crew & computer cleared.');
21-
launchReady = true;
22-
} else {
23-
console.log('WARNING: Crew or computer not ready!');
24-
launchReady = false;
25-
}
26-
27-
if (launchReady) {
28-
console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...');
29-
console.log('Liftoff!');
30-
} else {
31-
console.log('Launch scrubbed.');
3210
}

errors-and-debugging/exercises/DebuggingLogicErrors4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (fuelLevel >= 20000) {
1717
launchReady = false;
1818
}
1919

20-
console.log("launchReady = ", launchReady);
20+
console.log('launchReady');
2121

2222
if (crewStatus && computerStatus === 'green'){
2323
console.log('Crew & computer cleared.');

errors-and-debugging/exercises/DebuggingLogicErrors5.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Refactor the code to do this. Verify that your change works by updating the console.log statements.
44

55
let launchReady = false;
6+
let crewReady = false;
67
let fuelLevel = 17000;
78
let crewStatus = true;
89
let computerStatus = 'green';
@@ -14,15 +15,20 @@ if (fuelLevel >= 20000) {
1415
console.log('WARNING: Insufficient fuel!');
1516
launchReady = false;
1617
}
17-
1818
console.log("launchReady = ", launchReady);
1919

2020
if (crewStatus && computerStatus === 'green'){
21-
console.log('Crew & computer cleared.');
22-
launchReady = true;
21+
console.log('Crew && computer cleared.');
22+
cewReady = true;
2323
} else {
2424
console.log('WARNING: Crew or computer not ready!');
2525
launchReady = false;
2626
}
2727

28-
console.log("launchReady = ", launchReady);
28+
console.log("crewReady = ", crewReady);
29+
30+
if (launchReady = false){
31+
console.log("10, 9, 8, 7, 6, 5, 4, 3, 2, 1, Liftoff!");
32+
} else {
33+
console.log('Launch scrubbed.');
34+
}

errors-and-debugging/exercises/DebuggingRuntimeErrors2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let launchReady = false;
2-
let fuelLevel = 27000;
2+
let fuelLevel = 20000;
33

44
if (fuelLevel >= 20000) {
55
console.log('Fuel level cleared.');
@@ -9,12 +9,12 @@ if (fuelLevel >= 20000) {
99
launchReady = false;
1010
}
1111

12-
if (launchReady) {
12+
if (launchReady = true) {
1313
console.log("10, 9, 8...");
1414
console.log("Fed parrot...");
1515
console.log("6, 5, 4...");
1616
console.log("Ignition...");
17-
consoul.log("3, 2, 1...");
17+
console.log("3, 2, 1...");
1818
console.log("Liftoff!");
1919
} else {
2020
console.log("Launch scrubbed.");

errors-and-debugging/exercises/DebuggingSyntaxErrors2.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
//This block of code hides two syntax errors.
2-
3-
// Run the code and find the mistakes.
4-
// Only ONE error will be flagged at a time.
5-
// Fix that ONE problem, and then re-run the code to check yer work. Avoid trying to fix multiple issues at once.
6-
71
let launchReady = false;
82
let crewStatus = true;
93
let computerStatus = 'green';
104

11-
if (crewStatus &&& computerStatus === 'green'){
5+
if (crewStatus && computerStatus === 'green') {
126
console.log('Crew & computer cleared.');
137
launchReady = true;
148
} else {
@@ -17,7 +11,7 @@ if (crewStatus &&& computerStatus === 'green'){
1711
}
1812

1913
if (launchReady) {
20-
console.log(("10, 9, 8, 7, 6, 5, 4, 3, 2, 1...");
14+
console.log("10, 9, 8, 7, 6, 5, 4, 3, 2, 1...");
2115
console.log("Fed parrot...");
2216
console.log("Ignition...");
2317
console.log("Liftoff!");

0 commit comments

Comments
 (0)