Skip to content

Commit 060813b

Browse files
committed
completed tasks in 1-key-errors/2.js
1 parent c00019f commit 060813b

File tree

1 file changed

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

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
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 return a syntax error because the parameter is not a valid variable name as it is a number.
78

8-
function square(3) {
9-
return num * num;
10-
}
9+
// function square(3) {
10+
// return num * num;
11+
// }
1112

1213
// =============> write the error message here
13-
14+
//SyntaxError: Unexpected number
1415
// =============> explain this error message here
15-
16+
//Javascript identifiers cannot start with a number.
1617
// Finally, correct the code to fix the problem
1718

1819
// =============> write your new code here
1920

21+
function square(num) {
22+
return num ** 2;
23+
}
24+
25+
console.log(square(3));
2026

0 commit comments

Comments
 (0)