Skip to content

Commit b4435a7

Browse files
committed
Corrected square function; prints 9 for input 3
1 parent 9bcb86b commit b4435a7

File tree

1 file changed

+9
-6
lines changed
  • Sprint-2/1-key-errors

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
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 it will give an error because the function parameter can not be a number like (3).
78

8-
function square(3) {
9-
return num * num;
10-
}
11-
12-
// =============> write the error message here
9+
// =============> write the error message here
10+
// SyntaxError: Unexpected number
1311

1412
// =============> explain this error message here
15-
13+
// the parameter can't be a number like (3),also changing num * num to number instead to match the parameter.
1614
// Finally, correct the code to fix the problem
1715

1816
// =============> write your new code here
17+
function square(number) {
18+
return number * number;
19+
}
20+
console.log(square(3));
21+
1922

2023

0 commit comments

Comments
 (0)