Skip to content

Commit 4c0e0eb

Browse files
predict, explain and code
1 parent 2b742f7 commit 4c0e0eb

File tree

1 file changed

+19
-4
lines changed
  • Sprint-2/1-key-errors

1 file changed

+19
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,33 @@
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
1313

14-
// =============> explain this error message here
14+
function square(3) {
15+
return num * num;
16+
}
17+
18+
// =============> SyntaxError: Unexpected number
19+
20+
// =============> this is because variables and parameters in functions cannot start with a number or be a number
21+
// however, return can be used for calculations so my prediction was wrong
22+
1523

1624
// Finally, correct the code to fix the problem
1725

18-
// =============> write your new code here
26+
// =============>
27+
// function square (num) {
28+
// return num * num;
29+
// }
30+
// console.log(square(5));
31+
32+
// ran console.log to ensure it works
33+
1934

2035

0 commit comments

Comments
 (0)