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 44// this function should square any number but instead we're going to get an error
55
66// =============> 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+ // }
712
8- function square ( 3 ) {
9- return num * num ;
10- }
1113
1214// =============> write the error message here
15+ // SyntaxError: Unexpected number
1316
1417// =============> 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
1519
1620// Finally, correct the code to fix the problem
1721
1822// =============> write your new code here
23+ function square ( num ) {
24+ return num * num ;
25+ }
1926
20-
27+ console . log ( square ( 7 ) ) ;
You can’t perform that action at this time.
0 commit comments