Skip to content

Commit 5d023b1

Browse files
committed
error correction
1 parent 202d64e commit 5d023b1

File tree

1 file changed

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

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33

44
// this function should square any number but instead we're going to get an error
55

6-
// =============> write your prediction of the error here
6+
// =============> wrong syntax the number 3 should not be in function
77

88
function square(3) {
99
return num * num;
1010
}
1111

12-
// =============> write the error message here
12+
// =============> syntaxError: Unexpected number
1313

14-
// =============> explain this error message here
14+
// =============> when defining a function, the parentheses must contain parameter names, not values.
15+
// function square(3) is invalid because 3 is a value, not a parameter name.
1516

1617
// Finally, correct the code to fix the problem
1718

18-
// =============> write your new code here
19+
// =============>
20+
function square(num){return num*num};
21+
22+
console.log (square(3));
1923

2024

0 commit comments

Comments
 (0)