Skip to content

Commit 53921fe

Browse files
Fix parameter name
1 parent dc3752d commit 53921fe

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@
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 think using 3 will cause an error as parameter
8+
// A parameter must be a valid variable name, not a number
79

8-
function square(3) {
9-
return num * num;
10-
}
10+
/* function square(3){
11+
return num * num;
1112
12-
// =============> write the error message here
13+
}
14+
*/
15+
16+
// =============> write the error message here
17+
// SyntaxError: Unexpected number
1318

1419
// =============> explain this error message here
20+
// The parser sees the number 3 where it expects a valid parameter name,
21+
// so it cannot understand the structure of the function
22+
// It means we cannot use a number as a parameter name
23+
1524

1625
// Finally, correct the code to fix the problem
1726

1827
// =============> write your new code here
1928

29+
function square(num){
30+
return num * num;
2031

32+
}
33+
console.log(square(7));

0 commit comments

Comments
 (0)