-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.js
More file actions
25 lines (16 loc) · 785 Bytes
/
2.js
File metadata and controls
25 lines (16 loc) · 785 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...
// this function should square any number but instead we're going to get an error
// =============> I think that return can only return a value not do a calculation
// so this will return an error because it is trying to do a calculation instead of returning a value
function square(3) {
return num * num;
}
// =============> SyntaxError: Unexpected number
// =============> this is because variables and parameters in functions cannot start with a number or be a number
// however, return can be used for calculations so my prediction was wrong
// Finally, correct the code to fix the problem
// function square (num) {
// return num * num;
// }
// console.log(square(5));
// ran console.log to ensure it works