Skip to content

Commit b50bc9a

Browse files
changed function
1 parent 11b3da1 commit b50bc9a

File tree

1 file changed

+10
-5
lines changed
  • Sprint-2/1-key-errors

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33

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

6-
// =============> write your prediction of the error here
6+
// =============> I think that return can only return a value not do a calculation
7+
// so this will return an error because it is trying to do a calculation instead of returning a value
78

89
function square(3) {
910
return num * num;
1011
}
1112

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

14-
// =============> explain this error message here
15+
// =============> this is because variables and parameters in functions cannot start with a number or be a number
16+
// however, return can be used for calculations so my prediction was wrong
1517

1618
// Finally, correct the code to fix the problem
1719

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

25+
// ran console.log to ensure it works

0 commit comments

Comments
 (0)