Skip to content

Commit f3dab49

Browse files
committed
fix(sprint-2): resolve square SyntaxError by using valid parameter identifier
1 parent 5de912a commit f3dab49

File tree

1 file changed

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

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
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
6+
// SyntaxError: Function parameters must be valid identifiers, not number literals
77

8-
function square(3) {
9-
return num * num;
10-
}
8+
// function square(3) {
9+
// return num * num;
10+
// }
1111

1212
// =============> write the error message here
13+
// SyntaxError: Unexpected number
1314

1415
// =============> explain this error message here
16+
// Parameters must be valid identifiers (start with letter/underscore/$), not numbers
17+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_token
1518

1619
// Finally, correct the code to fix the problem
17-
1820
// =============> write your new code here
19-
20-
21+
function square(num) {
22+
return num * num;
23+
}

0 commit comments

Comments
 (0)