-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path2.js
More file actions
29 lines (19 loc) · 807 Bytes
/
2.js
File metadata and controls
29 lines (19 loc) · 807 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
26
27
// Predict and explain first BEFORE you run any code...
// Function parameters must be variables, not numbers.
// this function should square any number but instead we're going to get an error
// =============> write your prediction of the error here
// The code will give a SyntaxError because `3` is not a valid parameter name.
//function square(3) {
// return num * num;
// }
// =============> write the error message here
// SyntaxError: Unexpected number
// =============> explain this error message here
// The error happens because `3` is used as a parameter name.
// Parameters must be variable names, not numbers.
// Finally, correct the code to fix the problem
// =============> write your new code here
function square(number) {
return number * number;
}
console.log(square(3));