-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path2.js
More file actions
27 lines (17 loc) · 948 Bytes
/
2.js
File metadata and controls
27 lines (17 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Predict and explain first BEFORE you run any code...
// ====> As my understanding this function will throw and error as we have have not called the function with the argument 'num' .
// this function should square any number but instead we're going to get an error.
// ====> it will not square any number but 3 when we call it with the argument 'num' inside.
/*function square(3) {
return num * num;
}*/
// =============> write the error message here
// the error message is: SyntaxError: Unexpected number.
// =============> explain this error message here
// after running I understood that we can not put a value in function parameter but a variable name. to make it short, in JavaScript we put variable in parameter and value as argument when calling the function.
// Finally, correct the code to fix the problem
// =============> write your new code here
function square(num) {
return num * num;
}
console.log(square(9));