Skip to content

Commit a595ee0

Browse files
committed
Errors and Debugging Exercises
1 parent 586c4b0 commit a595ee0

8 files changed

+24
-14
lines changed

errors-and-debugging/exercises/Debugging1stSyntaxError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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 {

errors-and-debugging/exercises/DebuggingLogicErrors2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Consider the first if/else block below.
33
// Add console.log(launchReady) after this block, then run the program.
44

5-
//Given the fuelLevel value, should launchReady be true or false after the check? Is the program behaving as expected?
5+
//Given the fuelLevel value, should launchReady be true or false after the check? False. Is the program behaving as expected? Yes.
66

77
let launchReady = false;
88
let fuelLevel = 17000;
@@ -16,6 +16,7 @@ if (fuelLevel >= 20000) {
1616
console.log('WARNING: Insufficient fuel!');
1717
launchReady = false;
1818
}
19+
console.log(launchReady);
1920

2021
// if (crewStatus && computerStatus === 'green'){
2122
// console.log('Crew & computer cleared.');

errors-and-debugging/exercises/DebuggingLogicErrors3.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Now consider the second if/else block.
33
// Add another console.log(launchReady) after this block and run the program.
44

5-
// Given the values for crewStatus and computerStatus, should launchReady be true or false after the check?
6-
// Is the program behaving as expected?
5+
// Given the values for crewStatus and computerStatus, should launchReady be true or false after the check? Yes.
6+
// Is the program behaving as expected? Yes.
77

88
let launchReady = false;
99
// let fuelLevel = 17000;
@@ -25,6 +25,7 @@ if (crewStatus && computerStatus === 'green'){
2525
console.log('WARNING: Crew or computer not ready!');
2626
launchReady = false;
2727
}
28+
console.log(launchReady);
2829

2930
// if (launchReady) {
3031
// console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...');

errors-and-debugging/exercises/DebuggingLogicErrors4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Now consider both if/else blocks together (keeping the added console.log lines).
22
// Run the code and examine the output.
33

4-
// Given the values for fuelLevel, crewStatus and computerStatus, should launchReady be true or false?
5-
// Is the program behaving as expected?
4+
// Given the values for fuelLevel, crewStatus and computerStatus, should launchReady be true or false? False
5+
// Is the program behaving as expected? No
66

77
let launchReady = false;
88
let fuelLevel = 17000;

errors-and-debugging/exercises/DebuggingLogicErrors5.js

Lines changed: 12 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';
@@ -15,14 +16,21 @@ if (fuelLevel >= 20000) {
1516
launchReady = false;
1617
}
1718

18-
console.log("launchReady = ", launchReady);
19+
//console.log("launchReady = ", launchReady);
1920

2021
if (crewStatus && computerStatus === 'green'){
2122
console.log('Crew & computer cleared.');
22-
launchReady = true;
23+
crewReady = true;
2324
} else {
2425
console.log('WARNING: Crew or computer not ready!');
25-
launchReady = false;
26+
crewReady = false;
2627
}
2728

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

errors-and-debugging/exercises/DebuggingRuntimeErrors1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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 {

errors-and-debugging/exercises/DebuggingRuntimeErrors2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (launchReady) {
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let launchReady = false;
88
let crewStatus = true;
99
let computerStatus = 'green';
1010

11-
if (crewStatus &&& computerStatus === 'green'){
11+
if (crewStatus && computerStatus === 'green'){
1212
console.log('Crew & computer cleared.');
1313
launchReady = true;
1414
} else {
@@ -17,7 +17,7 @@ if (crewStatus &&& computerStatus === 'green'){
1717
}
1818

1919
if (launchReady) {
20-
console.log(("10, 9, 8, 7, 6, 5, 4, 3, 2, 1...");
20+
console.log("10, 9, 8, 7, 6, 5, 4, 3, 2, 1...");
2121
console.log("Fed parrot...");
2222
console.log("Ignition...");
2323
console.log("Liftoff!");

0 commit comments

Comments
 (0)