File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
Expand file tree Collapse file tree 1 file changed +19
-4
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+ // =============> I think that return can only return a value not do a calculation
7+ // so this will return an error because it is trying to do a calculation instead of returning a value
78
89function square ( 3 ) {
910 return num * num ;
1011}
1112
12- // =============> write the error message here
1313
14- // =============> explain this error message here
14+ function square ( 3 ) {
15+ return num * num ;
16+ }
17+
18+ // =============> SyntaxError: Unexpected number
19+
20+ // =============> this is because variables and parameters in functions cannot start with a number or be a number
21+ // however, return can be used for calculations so my prediction was wrong
22+
1523
1624// Finally, correct the code to fix the problem
1725
18- // =============> write your new code here
26+ // =============>
27+ // function square (num) {
28+ // return num * num;
29+ // }
30+ // console.log(square(5));
31+
32+ // ran console.log to ensure it works
33+
1934
2035
You can’t perform that action at this time.
0 commit comments