Skip to content

Commit 1028541

Browse files
committed
Completed 1.js exercise
1 parent e1af344 commit 1028541

File tree

1 file changed

+12
-0
lines changed
  • Sprint-2/1-key-errors

1 file changed

+12
-0
lines changed

Sprint-2/1-key-errors/1.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
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

811
function 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+
}

0 commit comments

Comments
 (0)