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
I added my predication and explaiened that an error will occur because the function paramater name is unvaild number . and changed the code after trying it by changing the function name to num be decalred and to work when I call the function.
Copy file name to clipboardExpand all lines: Sprint-2/1-key-errors/2.js
+19-4Lines changed: 19 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,32 @@
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 error will occur because the paramater of the function is not a valid variable name as it is a number.
8
+
// also the variable num is not declared in the function and this will give an error when the program run because the function will not know what the value of the num is.
7
9
8
10
functionsquare(3){
9
11
returnnum*num;
10
12
}
11
13
12
-
// =============> write the error message here
14
+
// =============> write the error message here
15
+
// function square(3) {
16
+
// ^
13
17
14
-
// =============> explain this error message here
18
+
// SyntaxError: Unexpected number
15
19
16
-
// Finally, correct the code to fix the problem
20
+
// =============> explain this error message here it means that the paramater of the function is an unexpected number (3) and this is not a valid variable number.
0 commit comments