Skip to content

Commit 38d9150

Browse files
committed
Reemoved hardcoded value and fixed console.log scope
1 parent 352f54e commit 38d9150

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

  • Sprint-3/1-key-errors

‎Sprint-3/1-key-errors/1.js‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,27 @@
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
18+
//The function has already declared the decimalNumber variable. The same variable cannot be used or declared twice.
19+
//The decimalNumber variable is only existing inside the the function. Therefore the console.log() will not have anything to print.
20+
//The decimalNumber must be called outside first.
21+
1822

1923
// Finally, correct the code to fix the problem
2024
// =============> write your new code here
25+
26+
function convertToPercentage(decimalNumber) {
27+
const percentage = `${decimalNumber * 100}%`;
28+
29+
return percentage;
30+
}
31+
console.log(convertToPercentage(0.5));

0 commit comments

Comments
 (0)