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
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
// Predict and explain first...
2
2
3
3
// Why will an error occur when this program runs?
4
-
// =============> write your prediction here
4
+
// =============> The variable decimalNumber has been declared twice and will retun an error.
5
5
6
6
// Try playing computer with the example to work out what is going on
7
7
@@ -14,7 +14,14 @@ function convertToPercentage(decimalNumber) {
14
14
15
15
console.log(decimalNumber);
16
16
17
-
// =============> write your explanation here
17
+
// =============> The variable decimalNumber has been declared twice and returned an error saying it had already been declared. There is also a console log error as it is trying to use a variable that is inside the function and hasn't been declared outside.
18
+
18
19
19
20
// Finally, correct the code to fix the problem
20
21
// =============> write your new code here
22
+
functionconvertToPercentage(decimalNumber){
23
+
constpercentage=`${decimalNumber*100}%`;
24
+
console.log(percentage);
25
+
returnpercentage;
26
+
}
27
+
//We can also use console log inside the function.
0 commit comments