File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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+ // I predict that I will get a SyntaxError as a parameter cannot
8+ // be a Number, parameters must be valid variable names.
79
8- function square ( 3 ) {
9- return num * num ;
10- }
10+ // function square(3) {
11+ // return num * num;
12+ // }
1113
12- // =============> write the error message here
14+ // =============> write the error message here:
15+ // SyntaxError: Unexpected number
1316
1417// =============> explain this error message here
18+ // Function parameters must be valid variable names, they must
19+ // follow the same naming rules. a number like 3 is not a valid
20+ // parameter name.
21+ // TO fix the code, rename the parameter to num (or any valid variable
22+ // name) and use it in the return statement.)
1523
1624// Finally, correct the code to fix the problem
1725
1826// =============> write your new code here
27+ function square ( num ) {
28+ return num * num ;
29+ }
1930
20-
31+ console . log ( square ( 3 ) ) ; // This should now work and output 9
You can’t perform that action at this time.
0 commit comments