File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 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 code will throw a syntax error because you cannot use a number as a function parameter.
8
+
9
+ // function square(3) {
10
+ // return num * num;
11
+ // }
7
12
8
- function square ( 3 ) {
9
- return num * num ;
10
- }
11
13
12
14
// =============> write the error message here
15
+ // SyntaxError: Unexpected number
13
16
14
17
// =============> explain this error message here
18
+ // Function parameters must be variable names, not values. Using a number as a parameter is invalid syntax in JavaScript -mdn
15
19
16
20
// Finally, correct the code to fix the problem
17
21
18
22
// =============> write your new code here
23
+ function square ( num ) {
24
+ return num * num ;
25
+ }
19
26
20
-
27
+ console . log ( square ( 7 ) ) ;
You can’t perform that action at this time.
0 commit comments