Skip to content

Commit 307d6b9

Browse files
- Replace literal number 3 with parameter identifier num
- resolve parameter syntax error in square function
1 parent e6a57a7 commit 307d6b9

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11

22
// Predict and explain first BEFORE you run any code...
3+
// Prediction: We will get an error definitely but i'm not sure if it's going to be a ReferenceError or a SyntaxError
34

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

67
// =============> write your prediction of the error here
78

8-
function square(3) {
9-
return num * num;
10-
}
9+
// function square(3) {
10+
// return num * num;
11+
// }
12+
13+
// console.log(square(2));
1114

1215
// =============> write the error message here
1316

17+
// =============> ERROR MESSAGE: SyntaxError: Unexpected number
18+
1419
// =============> explain this error message here
1520

21+
// =============> EXPLANATION: The SyntaxError: Unexpected number happened because the function was expecting an identifier in the parameter ('num') and not a number ('3') which triggered the error
22+
1623
// Finally, correct the code to fix the problem
1724

1825
// =============> write your new code here
1926

27+
function square(num) {
28+
return num * num;
29+
}
2030

31+
console.log(square(2));

0 commit comments

Comments
 (0)