File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed 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 think this is an obvious one because when defining a function you cant give a direct input like 3,
8+ // instead you have to give a variable name as a parameter and then use that variable name in the function
9+ // body to perform the calculation. So I predict that there will be a syntax error because of the way
10+ // the function is defined with a direct input of 3 instead of a variable name.
11+
12+ // function square(3) {
13+ // return num * num;
14+ // }
15+
716
8- function square ( 3 ) {
9- return num * num ;
10- }
1117
1218// =============> write the error message here
19+ // /Users/me/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/2.js:12
20+ // function square(3) {
21+ // ^
22+
23+ // SyntaxError: Unexpected number
1324
1425// =============> explain this error message here
26+ // This error message is saying that there is an unexpected number in the function definition, which is the number 3.
1527
1628// Finally, correct the code to fix the problem
1729
1830// =============> write your new code here
1931
32+ function square ( num ) {
33+ return num * num ;
34+ }
35+
36+ console . log ( square ( 3 ) ) ;
37+
2038
You can’t perform that action at this time.
0 commit comments