File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
22// Predict and explain first BEFORE you run any code...
33
4- // this function should square any number but instead we're going to get an error
4+ // the function square(3) wont work as you cant have a number value for the function.
55
66// =============> write your prediction of the error here
7+ // return num * num; wont work as
78
8- function square ( 3 ) {
9- return num * num ;
10- }
9+ // function square(3) {
10+ // return num * num;
11+ // }
1112
1213// =============> write the error message here
14+ // SyntaxError: Unexpected number
1315
1416// =============> explain this error message here
17+ // in the () is the parameter for the function and that cannot be a number as it has to be a name, following the same rules
18+ // that are used so it can't start with a number.
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
2027
28+ console . log ( square ( 3 ) ) ;
You can’t perform that action at this time.
0 commit comments