-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.js
More file actions
19 lines (13 loc) · 613 Bytes
/
Copy path1.js
File metadata and controls
19 lines (13 loc) · 613 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Predict and explain first...
// Why will an error occur when this program runs?
// =============> Line 9 the variable "decimalNumber" is declared as a parameter passed to the function
// but again on line 10 inside the function, the variable is declared
// Try playing computer with the example to work out what is going on
const decimalNumber = 0.5;
function convertToPercentage(decimalNumber) {
const percentage = `${decimalNumber * 100}%`;
return percentage;
}
console.log(convertToPercentage(decimalNumber));
// Finally, correct the code to fix the problem
// =============> decimalNumber = 0.5;