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 a SyntaxError, because 3 is a number, not a parameter name.
8+ // Function parameters must be identifiers (variable names).
79
8- function square ( 3 ) {
10+ function square ( num ) {
911 return num * num ;
1012}
1113
1214// =============> write the error message here
15+ // SyntaxError: Unexpected number
1316
1417// =============> explain this error message here
18+ // The original code was function square(3) { ... }. A function definition
19+ // expects a parameter name inside the brackets, but I gave it the value 3.
20+ // JavaScript found a number where it expected a name, so it says
21+ // "Unexpected number".
1522
1623// Finally, correct the code to fix the problem
1724
1825// =============> write your new code here
19-
26+ console . log ( square ( 3 ) ) ;
2027
You can’t perform that action at this time.
0 commit comments