Skip to content

Commit 686be02

Browse files
fixed the code to log the function and not the parameter
1 parent a318e04 commit 686be02

File tree

1 file changed

+15
-8
lines changed
  • Sprint-2/1-key-errors

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
// Predict and explain first...
22

33
// Why will an error occur when this program runs?
4-
// =============> write your prediction here
4+
// decimalNumber is already used as a parameter so it can not be used as a variable inside the function,
5+
// the code is logging the parameter instead of the function
56

67
// Try playing computer with the example to work out what is going on
78

9+
// function convertToPercentage(decimalNumber) {
10+
// const decimalNumber = 0.5;
11+
// const percentage = `${decimalNumber * 100}%`;
12+
13+
// return percentage;
14+
// }
15+
16+
// console.log(decimalNumber);
17+
18+
// I'm not sure about what to write here
19+
20+
// Finally, correct the code to fix the problem
821
function convertToPercentage(decimalNumber) {
9-
const decimalNumber = 0.5;
1022
const percentage = `${decimalNumber * 100}%`;
1123

1224
return percentage;
1325
}
1426

15-
console.log(decimalNumber);
16-
17-
// =============> write your explanation here
18-
19-
// Finally, correct the code to fix the problem
20-
// =============> write your new code here
27+
console.log(convertToPercentage(0.9))

0 commit comments

Comments
 (0)