Skip to content

Commit 47e6f25

Browse files
committed
Fix function parameter declaration and update error prediction comments
1 parent 4eaa3d3 commit 47e6f25

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
21
// Predict and explain first BEFORE you run any code...
32

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

6-
// =============> write your prediction of the error here
5+
// I predict the error will come from the argument because when we write a function we first declare parameters not values
76

8-
function square(3) {
7+
/*function square(3) {
98
return num * num;
10-
}
9+
}*/
1110

12-
// =============> write the error message here
11+
// SyntaxError: Unexpected number
1312

14-
// =============> explain this error message here
13+
// this error tells us javascript expects valid variable identifiers when function is defined not values
1514

1615
// Finally, correct the code to fix the problem
1716

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

0 commit comments

Comments
 (0)