Skip to content

Commit 6a28411

Browse files
committed
updated 2.js template
1 parent b3ada23 commit 6a28411

File tree

1 file changed

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

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@
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+
// I guess an error will be thrown because a number can not be a parameter.
78

89
function square(3) {
910
return num * num;
1011
}
11-
1212
// =============> write the error message here
13+
//SyntaxError: Unexpected number
1314

1415
// =============> explain this error message here
16+
// It does not know where the 3 came from. So instead of 3 it was supposed to be num.return num * num; does not work because num is not in the parameter.
1517

1618
// Finally, correct the code to fix the problem
1719

1820
// =============> write your new code here
21+
function square(num) {
22+
return num * num;
23+
}
24+
25+
console.log(square(3));
1926

2027

0 commit comments

Comments
 (0)