File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1-
21// Predict and explain first BEFORE you run any code...
32
43// this function should square any number but instead we're going to get an error
54
65// =============> write your prediction of the error here
7-
6+ // I guess the error is a reference error because the parameter is not defined correctly.
7+ /*
88function square(3) {
99 return num * num;
1010}
11-
11+ */
1212// =============> write the error message here
13+ // function square(3) {
14+ // ^
15+ //SyntaxError: Unexpected number
16+ // In fact, the error is a syntax error because number 3 is unexpected here.
1317
1418// =============> explain this error message here
19+ // Number 3 is not a valid parameter name, which is misplacing and causes a syntax error.
1520
1621// Finally, correct the code to fix the problem
1722
1823// =============> write your new code here
19-
20-
24+ function square ( num ) {
25+ return num * num ;
26+ }
27+ console . log ( square ( 3 ) ) ; // should return 9
You can’t perform that action at this time.
0 commit comments