Skip to content

Commit f818c7f

Browse files
committed
logged error and fixed code
1 parent 82a32ef commit f818c7f

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
21
// Predict and explain first BEFORE you run any code...
32

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

65
// I think this code will throw an error because we are passing an actual number into the parameters but javascript only allows a variable to be passed into the parameters that can be used to store information so i would need to change the number 3 into num ( and num here would act as the placeholder for any number passed in when the function gets called later) for this code to work because as it is i believe num would be undefined as it hasn't been defined anywhere.
76

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

12-
// =============> write the error message here
11+
// error message: SyntaxError: Unexpected number
1312

14-
// =============> explain this error message here
13+
// This error means javascript couldn't run the code because it doesn't accept numbers as a parameter.
1514

1615
// Finally, correct the code to fix the problem
1716

18-
// =============> write your new code here
17+
function square(num) {
18+
let numResult = num * num;
1919

20+
return numResult;
21+
}
2022

23+
console.log(square(3));

0 commit comments

Comments
 (0)