Skip to content

Commit b3ada23

Browse files
committed
updated 1.js PR template
1 parent 5dfb91e commit b3ada23

File tree

1 file changed

+9
-2
lines changed
  • Sprint-2/1-key-errors

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Why will an error occur when this program runs?
44
// =============> write your prediction here
5-
5+
// I guess decimalNumber is declared already so an error will be thrown.
66
// Try playing computer with the example to work out what is going on
77

88
function convertToPercentage(decimalNumber) {
@@ -15,6 +15,13 @@ function convertToPercentage(decimalNumber) {
1515
console.log(decimalNumber);
1616

1717
// =============> write your explanation here
18-
18+
// It is the same as i have predicted decimalNumber has already declared. And also there will be a reference error decimalNumber is logged outside the function.
1919
// Finally, correct the code to fix the problem
2020
// =============> write your new code here
21+
function convertToPercentage(decimalNumber) {
22+
const percentage = `${decimalNumber * 100}%`;
23+
return percentage;
24+
}
25+
26+
console.log(convertToPercentage(0.5));
27+

0 commit comments

Comments
 (0)