File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 33
44// this function should square any number but instead we're going to get an error
55
6- // =============> write your prediction of the error here
6+ // The function does not define the parameter correctly
7+ // Instead, the input has been inserted where the parameter name should be
8+ // Then num is being used in the function body but it is not defined anywhere
79
8- function square ( 3 ) {
9- return num * num ;
10- }
11-
12- // =============> write the error message here
10+ // function square(3) {
11+ // return num * num;
12+ // }
1313
14- // =============> explain this error message here
14+ // SyntaxError: Unexpected number
15+ // The number 3 is used directly in the function parameter
16+ // The function parameter should be num to accept any number as input
17+ // Then the function body can use num to square the input value
18+ //Defining a function should describe the parameters it expects, not specific values
1519
1620// Finally, correct the code to fix the problem
17-
18- // =============> write your new code here
21+ function square ( num ) {
22+ return num * num ;
23+ }
24+ console . log ( square ( 5 ) ) ;
25+ console . log ( square ( 10 ) ) ;
26+ console . log ( square ( - 3 ) ) ;
1927
2028
You can’t perform that action at this time.
0 commit comments