Skip to content

Commit 933dd7f

Browse files
Reflect new changes and new code.
1 parent c521ac2 commit 933dd7f

File tree

1 file changed

+13
-5
lines changed
  • Sprint-2/1-key-errors

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55

66
// Try playing computer with the example to work out what is going on
77

8-
function convertToPercentage(decimalNumber) {
98
const decimalNumber = 0.5;
109
const percentage = `${decimalNumber * 100}%`;
1110

1211
return percentage;
13-
}
1412

15-
console.log(decimalNumber);
1613

17-
// =============> write your explanation here
14+
// we already have a parameter "decimalNumber" which has been declared in the function. declaring it again with constant is going to give syntax error.
15+
// Also the console.log is trying to print "decimalNumber" which only exist in a function that is outside its scope.=============> write your explanation here
1816

1917
// Finally, correct the code to fix the problem
20-
// =============> write your new code here
18+
19+
20+
21+
function convertToPercentage(decimalNumber) {
22+
23+
const percentage = `${decimalNumber * 100}%`;
24+
return percentage;
25+
26+
}
27+
28+
console.log(convertToPercentage(0.5));// =============> write your new code here

0 commit comments

Comments
 (0)