Skip to content

Commit 058c055

Browse files
author
Payman IB
committed
Fix function definition and error explanations in square function example
1 parent 876bf7b commit 058c055

File tree

1 file changed

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

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
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+
// line 9 num is not defined.
78

8-
function square(3) {
9-
return num * num;
10-
}
9+
// function square(3) {
10+
// return num * num;
11+
//}
1112

1213
// =============> write the error message here
13-
14+
// SyntaxError: Unexpected number
1415
// =============> explain this error message here
15-
16+
// 3 is not a variable for the function to use. It should be a variable name like num or n.
1617
// Finally, correct the code to fix the problem
1718

1819
// =============> write your new code here
1920

20-
21+
function square(num) {
22+
return num * num;
23+
}
24+
console.log(square(3));

0 commit comments

Comments
 (0)