You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-2/1-key-errors/1.js
+15-6Lines changed: 15 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,28 @@
2
2
3
3
// Why will an error occur when this program runs?
4
4
// =============> write your prediction here
5
+
//There are two errors in the code. Firstly the variable decimalNumber is being used as a parameter to the function but is then redeclared in the function. Secondly the console log is trying to access a variable that is not in its scope.
5
6
6
7
// Try playing computer with the example to work out what is going on
7
8
8
-
functionconvertToPercentage(decimalNumber){
9
-
constdecimalNumber=0.5;
10
-
constpercentage=`${decimalNumber*100}%`;
9
+
// function convertToPercentage(decimalNumber) {
10
+
// const decimalNumber = 0.5;
11
+
// const percentage = `${decimalNumber * 100}%`;
11
12
12
-
returnpercentage;
13
-
}
13
+
// return percentage;
14
+
// }
14
15
15
-
console.log(decimalNumber);
16
+
// console.log(decimalNumber);
16
17
17
18
// =============> write your explanation here
19
+
//line 9 creates a a new variable called decimal number, then on line 10 the code attempts to declare a new variable with the same name and thus a syntax error is thrown.
0 commit comments