Skip to content

Commit ee8e2c7

Browse files
Fix parameter in square function and add explanations
Corrected the function parameter and added comments explaining the error.
1 parent 416eee5 commit ee8e2c7

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

  • Sprint-2/1-key-errors

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
21
// Predict and explain first BEFORE you run any code...
32

3+
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+
7+
// =============> It is going to throw an error message as 3 is written in incorrect position. That position is set only for parameters, not arguments.
8+
79

810
function square(3) {
911
return num * num;
1012
}
1113

12-
// =============> write the error message here
1314

14-
// =============> explain this error message here
15+
// =============> in the node repl, it says unexpected number, as the function always expects a parameter to be declared in its definition.
16+
17+
18+
// =============> The error is already described above.
19+
1520

1621
// Finally, correct the code to fix the problem
1722

18-
// =============> write your new code here
23+
24+
/* ===========> function square(num) {
25+
return num * num;
26+
}
27+
*/
28+
1929

2030

0 commit comments

Comments
 (0)