Skip to content

Commit 6ebd7bb

Browse files
committed
answered 2-mandatory-debugs 0.js
1 parent 5986205 commit 6ebd7bb

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

  • Sprint-3

‎Sprint-3/1-key-errors/2.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Predict and explain first BEFORE you run any code...
32

43
// this function should square any number but instead we're going to get an error
@@ -20,7 +19,7 @@
2019

2120
// =============> write your new code here
2221
function square(num) {
23-
return num * num;
22+
return num * num;
2423
}
2524

26-
console.log(square(3))
25+
console.log(square(3));

‎Sprint-3/2-mandatory-debug/0.js‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4+
// local scope code did not return to global.
45

5-
function multiply(a, b) {
6-
console.log(a * b);
7-
}
6+
//function multiply(a, b) {
7+
// console.log(a * b);
8+
//}
89

9-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10+
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1011

1112
// =============> write your explanation here
13+
// The calculation of the a * b should apply the the statement (`The result of multiplying 10 and 32 is ${multiply(10, 32)}`).
14+
// because code on local scope did not return to global. The global cannot apply the result of local.
1215

1316
// Finally, correct the code to fix the problem
1417
// =============> write your new code here
18+
19+
function multiply(a, b) {
20+
return a * b;
21+
}
22+
23+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)