Skip to content

Commit 5e632d2

Browse files
committed
the error is predicted before running the code and then explained the error. and finally, rewrote the code to fix the problem.
1 parent c2e158f commit 5e632d2

File tree

1 file changed

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

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
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+
// =============> write your prediction of the error here: the error might be inside the function "the square number" or might be num is not identified.//
77

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

12-
// =============> write the error message here
12+
// =============> write the error message here: Uncaught syntaxError: Unexpected number.//
1313

14-
// =============> explain this error message here
14+
// =============> explain this error message here: This error occurs because the function parameter is not defined correctly. Instead of passing a number directly, we should use a variable name. In this case, we can use "num" as the parameter name.
1515

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

18+
1819
// =============> write your new code here
20+
// function square(num) {
21+
// return num * num;
22+
// }
1923

2024

0 commit comments

Comments
 (0)