Skip to content

Commit 9f55529

Browse files
committed
Fixed function declaration and update error explanations in square function
1 parent 7570924 commit 9f55529

File tree

1 file changed

+6
-3
lines changed
  • Sprint-2/1-key-errors

1 file changed

+6
-3
lines changed

Sprint-2/1-key-errors/2.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
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 error message will be about 'num' not being declared.
77

88
function square(3) {
99
return num * num;
1010
}
1111

12-
// =============> write the error message here
12+
// =============> Uncaught SyntaxError: Illegal return statement.
1313

14-
// =============> explain this error message here
14+
// =============> The error message is because this num is not a valid variable as it has been undeclared.
1515

1616
// Finally, correct the code to fix the problem
1717

1818
// =============> write your new code here
19+
function square(num) {
20+
return num * num;
21+
}
1922

2023

0 commit comments

Comments
 (0)