Skip to content

Commit fcb215c

Browse files
committed
2.js
1 parent d8487ec commit fcb215c

File tree

1 file changed

+11
-4
lines changed
  • Sprint-2/1-key-errors

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
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+
// The code will throw a syntax error because you cannot use a number as a function parameter.
8+
9+
// function square(3) {
10+
// return num * num;
11+
// }
712

8-
function square(3) {
9-
return num * num;
10-
}
1113

1214
// =============> write the error message here
15+
// SyntaxError: Unexpected number
1316

1417
// =============> explain this error message here
18+
// Function parameters must be variable names, not values. Using a number as a parameter is invalid syntax in JavaScript -mdn
1519

1620
// Finally, correct the code to fix the problem
1721

1822
// =============> write your new code here
23+
function square(num) {
24+
return num * num;
25+
}
1926

20-
27+
console.log(square(7));

0 commit comments

Comments
 (0)