Skip to content

Commit 6f4e46f

Browse files
author
russom
committed
Predict, explain and fix code
1 parent 507f02a commit 6f4e46f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55

66
// =============> write your prediction of the error here
77

8+
// Prediction:
9+
// 1. This will give reference error.
10+
//
11+
12+
813
function square(3) {
914
return num * num;
1015
}
1116

1217
// =============> write the error message here
18+
//
19+
// SyntaxError: Unexpected number
1320

1421
// =============> explain this error message here
1522

23+
// The function expects a parameter name and it shouldn't start with a number.
24+
// num should be the parameter and later 3 can be passed as an argument.
25+
1626
// Finally, correct the code to fix the problem
1727

1828
// =============> write your new code here
1929

30+
function square(num) {
31+
return num * num;
32+
}
33+
34+
console(square(3));
2035

0 commit comments

Comments
 (0)