File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 11
22// Predict and explain first BEFORE you run any code...
3+ // Function parameters must be variables, not numbers.
34
45// this function should square any number but instead we're going to get an error
56
67// =============> write your prediction of the error here
8+ // The code will give a SyntaxError because `3` is not a valid parameter name.
79
8- function square ( 3 ) {
9- return num * num ;
10- }
10+ // function square(3) {
11+ // return num * num;
12+ // }
1113
1214// =============> write the error message here
15+ // SyntaxError: Unexpected number
1316
1417// =============> explain this error message here
15-
18+ // The error happens because `3` is used as a parameter name.
19+ // Parameters must be variable names, not numbers.
1620// Finally, correct the code to fix the problem
1721
1822// =============> write your new code here
1923
24+ function square ( number ) {
25+ return number * number ;
26+ }
27+ console . log ( square ( 3 ) ) ;
28+
2029
You can’t perform that action at this time.
0 commit comments