Skip to content

Commit 4b743c8

Browse files
committed
fix code, explain fix
1 parent fa98548 commit 4b743c8

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

  • Sprint-2/1-key-errors

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
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
54

65
// =============> write your prediction of the error here
7-
8-
function square(3) {
6+
//=========Prediction=============
7+
// I think there will not be en error till we call the function.
8+
/*function square(num) {
99
return num * num;
1010
}
11-
11+
console.log(square(5))*/
1212
// =============> write the error message here
13-
13+
// Unexpected number
1414
// =============> explain this error message here
15-
15+
// I think it
1616
// Finally, correct the code to fix the problem
17-
17+
// ===========correction=========
18+
// to correct the code we need to introduce parameter as a variable, rather than a number.
19+
// that way any number can be passed when function is called.
1820
// =============> write your new code here
19-
20-
21+
function square(num) {
22+
return num * num;
23+
}
24+
console.log(square(5));

0 commit comments

Comments
 (0)