File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 33// Why will an error occur when this program runs?
44// =============> write your prediction here
55
6+ // Because of the variable name collision. The function parameter is called decimalNumber
7+ // but another decimalNumber is declared inside the body of the function.
8+
69// Try playing computer with the example to work out what is going on
710
811function convertToPercentage ( decimalNumber ) {
@@ -16,5 +19,14 @@ console.log(decimalNumber);
1619
1720// =============> write your explanation here
1821
22+ // The console prints: SyntaxError: Identifier 'decimalNumber' has already been declared
23+
1924// Finally, correct the code to fix the problem
2025// =============> write your new code here
26+
27+ function percentaged ( decimalNumber ) {
28+ const constant = 0.5 ;
29+ const percentage = `${ constant * 100 } %` ;
30+
31+ return percentage ;
32+ }
You can’t perform that action at this time.
0 commit comments