Skip to content

Commit 95efc71

Browse files
reset file Sprint-2/1-key-errors/1.js
1 parent 100b9fd commit 95efc71

File tree

1 file changed

+3
-10
lines changed
  • Sprint-2/1-key-errors

1 file changed

+3
-10
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@
22

33
// Why will an error occur when this program runs?
44
// =============> write your prediction here
5-
// decimalNumber variable was declared twice. First as parameter and second as const in function body
6-
// use different variable name, either in parameter or the one in function body.
7-
// any way this function always return the same value because the variable is constant and define inside th function,
8-
// usually a function take a variable from function parameters.
9-
// console.log() will fail to print because no parameter define first.
5+
106
// Try playing computer with the example to work out what is going on
117

128
function convertToPercentage(decimalNumber) {
13-
//-----> should be place as parameter and not as a constant ,,,,,const decimalNumber = 0.5;
9+
const decimalNumber = 0.5;
1410
const percentage = `${decimalNumber * 100}%`;
1511

1612
return percentage;
1713
}
1814

19-
decimalNumber = 0.27;
20-
21-
console.log(decimalNumber); //this is fine, just define the parameter it needs.
22-
console.log(convertToPercentage(decimalNumber));
15+
console.log(decimalNumber);
2316

2417
// =============> write your explanation here
2518

0 commit comments

Comments
 (0)