You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a44bb25
Browse filesBrowse the repository at this point in the historyBrowse files
// Why will an error occur when this program runs?
4
+
//- variable name "decimalNumber" declared twice in the same function. one as function parameter and again as a const in the same function.
4
5
// =============> write your prediction here
5
-
6
+
//- SyntaxError because "decimalNumber" declared twice.
6
7
// Try playing computer with the example to work out what is going on
7
8
8
-
functionconvertToPercentage(decimalNumber){
9
-
constdecimalNumber=0.5;
10
-
constpercentage=`${decimalNumber*100}%`;
9
+
// function convertToPercentage(decimalNumber) {
10
+
// const decimalNumber= 0.5;
11
+
// const percentage = `${decimalNumber * 100}%`;
11
12
12
-
returnpercentage;
13
-
}
13
+
// return percentage;
14
+
// }
14
15
15
-
console.log(decimalNumber);
16
+
// console.log(decimalNumber);
16
17
17
18
// =============> write your explanation here
18
-
19
+
//- "decimalNumber" is already provided as a parameter to the function, but I don't need a parameter because I'm creating the value "0.5" inside the function. So I removed the parameter. I also need to call the function with convertToPercentage() instead of console.log(decimalNumber) because "decimalNumber" only exists inside the function.
0 commit comments