Skip to content

Commit dab62aa

Browse files
modified the function to correctly square a number
1 parent a15ff43 commit dab62aa

File tree

1 file changed

+11
-8
lines changed
  • Sprint-2/1-key-errors

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11

2-
// Predict and explain first BEFORE you run any code...
2+
// Predict and explain first BEFORE you run any code: the function is supposed to return the square of the number.
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+
// =============> write your prediction of the error here: Maybe because we used a number instead of a variable inside the function declaration.
77

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

12-
// =============> write the error message here
12+
// =============> write the error message here : syntax error: Unexpected number (3)
1313

14-
// =============> explain this error message here
14+
// =============> explain this error message here: we shouldn't use a number as a parametre name of the function.
1515

1616
// Finally, correct the code to fix the problem
1717

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

0 commit comments

Comments
 (0)