Skip to content

Commit 001939b

Browse files
committed
complete ex 2.js
1 parent 6570ced commit 001939b

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 8 additions & 7 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

65
// =============> // I predict a SyntaxError because 3 is a number, but a function parameter needs to be a name.
76

8-
function square(3) {
7+
/*function square(3) {
98
return num * num;
109
}
10+
*/
11+
// =============> SyntaxError: Unexpected number
1112

12-
// =============> write the error message here
13-
14-
// =============> explain this error message here
13+
// =============> The error happens because 3 is not a name. A parameter needs a name, like num.
1514

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

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

0 commit comments

Comments
 (0)