Skip to content

Commit ce9e5c1

Browse files
reset Sprint-2/1-key-errors/2.js
1 parent 95efc71 commit ce9e5c1

File tree

1 file changed

+6
-15
lines changed
  • Sprint-2/1-key-errors

1 file changed

+6
-15
lines changed

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1+
12
// Predict and explain first BEFORE you run any code...
23

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

56
// =============> write your prediction of the error here
6-
//the function will return square for every given number.
77

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

1212
// =============> write the error message here
13-
// ans: Unexpected number
1413

1514
// =============> explain this error message here
16-
// ans: function need num to be defined, instead parameter was given 3 as literal value that does not point to any variable as parameter
17-
// Finally, correct the code to fix the problem
18-
19-
// =============> write your new code here
2015

21-
function square(num) {
22-
return num * num;
23-
}
24-
25-
mynum = 3; //define the num
16+
// Finally, correct the code to fix the problem
2617

27-
console.log(square(mynum)); //verify the result
18+
// =============> write your new code here

0 commit comments

Comments
 (0)