You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-2/1-key-errors/2.js
+14-2Lines changed: 14 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,29 @@
4
4
// this function should square any number but instead we're going to get an error
5
5
6
6
// =============> write your prediction of the error here
7
+
// The function is defined incorrectly using a number as a parameter name so it will throw an error when called because looking for an identifier but finds a number instead.
7
8
8
-
functionsquare(3){
9
+
/* function square(3) {
9
10
return num * num;
10
11
}
12
+
*/
11
13
12
14
// =============> write the error message here
15
+
/* function square(3) {
16
+
^
13
17
18
+
SyntaxError: Unexpected number
19
+
*/
14
20
// =============> explain this error message here
21
+
// SyntaxError: This means there is something wrong with the way the code is written, so JavaScript cannot understand it.
22
+
// unexpected number: This means that the code is trying to use a number where it expects an identifier (like a variable name). In this case, the function parameter is incorrectly named as a number (3) instead of a valid identifier.
15
23
16
24
// Finally, correct the code to fix the problem
25
+
// to fix the problem, we need to change the parameter name to a valid identifier, like "num" or "number".
0 commit comments