Skip to content

Commit 9485482

Browse files
authored
Fix parameter name in square function
Corrected the parameter name in the square function to avoid SyntaxError.
1 parent 3b49e4d commit 9485482

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 6 additions & 0 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+
// A SyntaxError will occur because 3 is not a valid parameter name.
78

89
function square(3) {
910
return num * num;
1011
}
1112

1213
// =============> write the error message here
14+
// SyntaxError: Unexpected number
1315

1416
// =============> explain this error message here
17+
// A parameter must be an identifier (variable name), but 3 is a number.
1518

1619
// Finally, correct the code to fix the problem
1720

1821
// =============> write your new code here
22+
function square(num) {
23+
return num * num;
24+
}
1925

2026

0 commit comments

Comments
 (0)