Skip to content

Commit 5986205

Browse files
committed
answered 1-key-errors 2.js
1 parent ef1ddd5 commit 5986205

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
44
// this function should square any number but instead we're going to get an error
55

66
// =============> write your prediction of the error here
7+
// The code in local scope could not refer to variable. function square should attach with a variable instead of value.
78

8-
function square(3) {
9-
return num * num;
10-
}
9+
//function square(3) {
10+
// return num * num;
11+
//}
1112

1213
// =============> write the error message here
14+
//SyntaxError: Unexpected number
1315

1416
// =============> explain this error message here
17+
// the error caused by the wrong input for the variable "square(3)".
1518

1619
// Finally, correct the code to fix the problem
1720

1821
// =============> write your new code here
22+
function square(num) {
23+
return num * num;
24+
}
1925

20-
26+
console.log(square(3))

0 commit comments

Comments
 (0)