Skip to content

Commit 005b56a

Browse files
committed
Slove problem in 2.js
1 parent dca0ac7 commit 005b56a

File tree

1 file changed

+9
-7
lines changed
  • Sprint-2/1-key-errors

1 file changed

+9
-7
lines changed

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

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

6-
// =============> write your prediction of the error here
5+
// =============> write your prediction of the error here : There will be a syntax error because the parameter name cannot be a number.
76

8-
function square(3) {
9-
return num * num;
7+
function square(3) {
8+
return num * num;
109
}
1110

12-
// =============> write the error message here
11+
// =============> write the error message here : SyntaxError: Unexpected number.
1312

14-
// =============> explain this error message here
13+
// =============> explain this error message here : /*The error message shows that there is an unexpected number in the function parameter name. Function parameters must be valid identifiers (like variable names) and cannot be numeric literals.*/
1514

1615
// Finally, correct the code to fix the problem
1716

1817
// =============> write your new code here
1918

20-
19+
function square(num) {
20+
return num * num;
21+
}
22+
console.log(square(3));

0 commit comments

Comments
 (0)