Skip to content

Commit 3e44896

Browse files
fix the problem
1 parent caa6042 commit 3e44896

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
21
// Predict and explain first BEFORE you run any code...
2+
// when we run the code, I predict that we will got the error in function argument
3+
//because it is not a variable
34

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

67
// =============> write your prediction of the error here
8+
//
79

8-
function square(3) {
10+
/*function square(3) {
911
return num * num;
10-
}
12+
}*/
1113

1214
// =============> write the error message here
15+
// SyntaxError: Unexpected number
1316

1417
// =============> explain this error message here
18+
// The error occurs because 3 is a number, not a valid variable name.
1519

1620
// Finally, correct the code to fix the problem
1721

1822
// =============> write your new code here
19-
20-
23+
const num = 3;
24+
function square(num) {
25+
return num * num;
26+
}
27+
console.log(square(num));

0 commit comments

Comments
 (0)