Skip to content

Commit 72f37f5

Browse files
committed
resolve and explain syntax error in Sprint-2 > 1-key-errors > 2.js
1 parent 6ca5625 commit 72f37f5

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • Sprint-2/1-key-errors

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
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+
// =============> we should put num in the input of the function, instead of 3
77

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

12-
// =============> write the error message here
12+
// =============>
13+
//Uncaught SyntaxError SyntaxError: Unexpected number
1314

1415
// =============> explain this error message here
15-
16+
//3 is unexpected. when we define a function we want to give it parameter(s), not a specific number. it is when the function is called that we want to give it specific values to pass in.
1617
// Finally, correct the code to fix the problem
1718

1819
// =============> write your new code here
19-
20+
function square(num) {
21+
return num * num;
22+
}
2023

0 commit comments

Comments
 (0)