Skip to content

Commit c642719

Browse files
committed
Answering the task
1 parent 15dadf1 commit c642719

File tree

1 file changed

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

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11

2+
23
// Predict and explain first BEFORE you run any code...
34

45
// this function should square any number but instead we're going to get an error
56

6-
// =============> write your prediction of the error here
7+
// =============> The num parameter should be mentioned inside the function square instead of the number 3.
8+
// then it should be called as square (3) in the console.log statement.
79

8-
function square(3) {
9-
return num * num;
10-
}
10+
//function square(3) {
11+
//return num * num;
12+
//}
13+
14+
// =============> function square(3) syntaxError: Unexpected number.
15+
// =============> 3 wasn't expected... instead a declaration like 'num' was expected.
1116

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

14-
// =============> explain this error message here
1518

1619
// Finally, correct the code to fix the problem
1720

1821
// =============> write your new code here
22+
function square(num) {
23+
return num * num;
24+
}
1925

20-
26+
console.log(square(3));

0 commit comments

Comments
 (0)