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
// Predict and explain first BEFORE you run any code...
3
3
4
+
// The code has a syntax error because a number is used instead of a parameter name in the function definition.
5
+
// Additionally, num is used inside the function without being declared or passed as an argument, which causes a ReferenceError.
6
+
// If the function is not called, it will not execute.
4
7
// this function should square any number but instead we're going to get an error
5
8
6
9
// =============> write your prediction of the error here
7
10
8
-
functionsquare(3){
11
+
// The code has a syntax error because a number is used instead of a parameter name in the function definition.
12
+
// Additionally, num is used inside the function without being declared or passed as an argument, which causes a ReferenceError.
13
+
// If the function is not called, it will not execute.
14
+
15
+
functionsquare(num){
9
16
returnnum*num;
10
17
}
18
+
letnum=square(3);
19
+
console.log(num);
20
+
11
21
12
22
// =============> write the error message here
23
+
// syntax error :unexpected number.
13
24
14
25
// =============> explain this error message here
26
+
// The error occurs because a number is used in the function definition instead of a parameter name. A function definition must contain a parameter (a variable name), not a value.
27
+
28
+
// Inside the function, num is used but it was never declared or passed as a parameter, which causes a ReferenceError because num is not defined in the scope.
29
+
30
+
// Also, if the function is not called, it will not execute.
0 commit comments