Skip to content

Commit fb93c79

Browse files
committed
task 2.js completed
1 parent 79db8a6 commit fb93c79

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • Sprint-3/1-key-errors

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

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

22
// Predict and explain first BEFORE you run any code...
3+
// Answer below:
4+
// The code will not work because the placeholder variable (3) should be an actual name like "num"
5+
36

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

69
// =============> write your prediction of the error here
710

8-
function square(3) {
9-
return num * num;
10-
}
11+
// function square(3) {
12+
// return num * num;
13+
// }
14+
15+
1116

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

1420
// =============> explain this error message here
21+
// The error message explains the error in the function parameter (3), the function expects a name parameter instead of a number.
1522

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+
}
30+
console.log(square(10))
31+
32+
2033

0 commit comments

Comments
 (0)