Skip to content

Commit 36a8256

Browse files
change the function assigning the variable num .
1 parent 2cb2539 commit 36a8256

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11

22
// Predict and explain first BEFORE you run any code...
3+
// It show the reference error cause function not assigned the variable so that, code is stuck.
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
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+
// the message is SyntaxError: Unexpected number.
1315

1416
// =============> explain this error message here
17+
// The error message is occured due to not assigning the variable in function. TO solve this problems we need to assign the num variable in function.
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+
}
25+
26+
console.log(square(3));
27+
// The output of this programme is 9.
28+
1929

2030

0 commit comments

Comments
 (0)