File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// Why will an error occur when this program runs?
4- // =============> write your prediction here
4+ // =============> because first: the variable decimalNumber is declared twice
5+ // second: the parameter decimalNumber is assigned to a value inside the function
56
67// Try playing computer with the example to work out what is going on
78
@@ -14,7 +15,13 @@ function convertToPercentage(decimalNumber) {
1415
1516console . log ( decimalNumber ) ;
1617
17- // =============> write your explanation here
18+ // =============> Identifier 'decimalNumber' has already been declared is the error msg thrown by the code
1819
1920// Finally, correct the code to fix the problem
20- // =============> write your new code here
21+ // =============>
22+ function convertToPercentage ( decimalNumber ) {
23+ // const decimalNumber = 0.5; this line must be deleted
24+ const percentage = `${ decimalNumber * 100 } %` ;
25+
26+ return percentage ;
27+ }
You can’t perform that action at this time.
0 commit comments