Skip to content

Commit 440f0f1

Browse files
committed
Sprint-2, 1-key-errors, 2.js done
1 parent 869c420 commit 440f0f1

File tree

1 file changed

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

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@
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+
// num has not been defined and the parameter is not used in the function;
8+
// it has a number instead
9+
710

811
function square(3) {
912
return num * num;
1013
}
1114

1215
// =============> write the error message here
16+
// SyntaxError: Unexpected number
17+
1318

1419
// =============> explain this error message here
20+
// The error message is saying that it was not expecting a number in the function
21+
// declaration. This is because the parameter should be a variable name, not a number
1522

1623
// Finally, correct the code to fix the problem
1724

1825
// =============> write your new code here
19-
26+
function square(num) {
27+
return num * num;
28+
}
2029

0 commit comments

Comments
 (0)