File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change 55
66// Try playing computer with the example to work out what is going on
77
8- function convertToPercentage ( decimalNumber ) {
9- const decimalNumber = 0.5 ;
10- const percentage = `${ decimalNumber * 100 } %` ;
8+ // function convertToPercentage(decimalNumber) {
9+ // const decimalNumber = 0.5;
10+ // const percentage = `${decimalNumber * 100}%`;
1111
12- return percentage ;
13- }
12+ // return percentage;
13+ // }
1414
15- console . log ( decimalNumber ) ;
15+ // console.log(decimalNumber);
1616
1717// =============> write your explanation here
1818
19+ // declaration variable name has been declared the same in the function declaration
20+ //(decimalNumber) and inside the function in a new variable line 9 = const decimalNumber
21+
22+ //SyntaxError: Identifier 'decimalNumber' has already been declared
23+
24+
25+
1926// Finally, correct the code to fix the problem
2027// =============> write your new code here
28+ //using the function with any code:
29+
30+ function convertToPercentage ( decimalNumber ) {
31+
32+ const percentage = `${ decimalNumber * 100 } %` ;
33+
34+ return percentage ;
35+ }
36+
37+ console . log ( convertToPercentage ( 0.5 ) ) ;
38+ console . log ( convertToPercentage ( 2 ) ) ;
You can’t perform that action at this time.
0 commit comments