Skip to content

Commit f2c1b80

Browse files
fix: update comments to clarify function behavior and correct code formatting in square function
1 parent 5c410d8 commit f2c1b80

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

  • Sprint-3/1-key-errors

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

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

22
// Predict and explain first BEFORE you run any code...
3+
// The function won't return be able to return the value to the caller, due to the expression not being assigned.
34

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

6-
// =============> write your prediction of the error here
7+
// The expression will return as unexpected number in the console log
78

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

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

14-
// =============> explain this error message here
15+
// The parameter set by the function isn't attached to the num value of the return, so the return doesn't have a value to work with
1516

1617
// Finally, correct the code to fix the problem
1718

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

2026

0 commit comments

Comments
 (0)