Skip to content

Commit 31d1742

Browse files
committed
Comment out code in convertToPercentage function to prevent SyntaxError due to variable declaration conflict
1 parent 8f96ad7 commit 31d1742

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77

88
// Try playing computer with the example to work out what is going on
99

10-
function convertToPercentage(decimalNumber) {
11-
// The parameter 'decimalNumber' is created as a variable inside the function's scope.
12-
const decimalNumber = 0.5;
13-
// tries to declare new variable called 'decimalNumber' in the same scope, where one already exists as a parameter
14-
// cannot declare same name twice in one scope with 'const'
15-
const percentage = `${decimalNumber * 100}%`;
10+
// function convertToPercentage(decimalNumber) {
11+
// // The parameter 'decimalNumber' is created as a variable inside the function's scope.
12+
// const decimalNumber = 0.5;
13+
// // tries to declare new variable called 'decimalNumber' in the same scope, where one already exists as a parameter
14+
// // cannot declare same name twice in one scope with 'const'
15+
// const percentage = `${decimalNumber * 100}%`;
1616

17-
return percentage;
18-
}
19-
// As a result of the conflict nothing runs.
20-
console.log(decimalNumber);
21-
// This line is outside the function and would not parse, as 'decimalNumber' only exists inside 'convertToPercentage' as a parameter.
17+
// return percentage;
18+
// }
19+
// // As a result of the conflict nothing runs.
20+
// console.log(decimalNumber);
21+
// // This line is outside the function and would not parse, as 'decimalNumber' only exists inside 'convertToPercentage' as a parameter.
2222

2323
// =============> write your explanation here
2424
// Parameters and variables declared inside a function cannot be accessed outside it.
25-
25+
2626
// Finally, correct the code to fix the problem
2727
// =============> write your new code here

0 commit comments

Comments
 (0)