Skip to content

Commit 8ad9d08

Browse files
committed
reverted changes to 1.js
1 parent 78f21df commit 8ad9d08

File tree

1 file changed

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

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22

33
// Why will an error occur when this program runs?
44
// =============> write your prediction here
5-
//decimalNumber does not exist outside the scope of the convertToPercentage funtion so the log will throw an error saying it has not been declared.
65

76
// Try playing computer with the example to work out what is going on
87

98
function convertToPercentage(decimalNumber) {
10-
//const decimalNumber = 0.5;
9+
const decimalNumber = 0.5;
1110
const percentage = `${decimalNumber * 100}%`;
1211

1312
return percentage;
1413
}
1514

16-
console.log(convertToPercentage(0.5));
15+
console.log(decimalNumber);
1716

1817
// =============> write your explanation here
19-
//decimalNumber is passed as a parameter when the function is called, line 10 tries to declare it again and assign it a new fixed value. we would need to remove that line so we can use the value passed in with the function call.
20-
//decimalNumber only exists inside the function scope so console.log cannot access it an error will be thrown. we need to instead pass the function to console.log.
18+
2119
// Finally, correct the code to fix the problem
2220
// =============> write your new code here

0 commit comments

Comments
 (0)