Skip to content

Commit 24f2d3c

Browse files
committed
In 1-key-errors/2.js, replacing 3 with num as parameter
1 parent 8fdb210 commit 24f2d3c

File tree

1 file changed

+12
-5
lines changed
  • Sprint-2/1-key-errors

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
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-
6+
// I guess the error is a reference error because the parameter is not defined correctly.
7+
/*
88
function square(3) {
99
return num * num;
1010
}
11-
11+
*/
1212
// =============> write the error message here
13+
// function square(3) {
14+
// ^
15+
//SyntaxError: Unexpected number
16+
// In fact, the error is a syntax error because number 3 is unexpected here.
1317

1418
// =============> explain this error message here
19+
// Number 3 is not a valid parameter name, which is misplacing and causes a syntax error.
1520

1621
// Finally, correct the code to fix the problem
1722

1823
// =============> write your new code here
19-
20-
24+
function square(num) {
25+
return num * num;
26+
}
27+
console.log(square(3)); // should return 9

0 commit comments

Comments
 (0)