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
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,24 @@
5
5
6
6
// Try playing computer with the example to work out what is going on
7
7
8
-
functionconvertToPercentage(decimalNumber){
9
8
constdecimalNumber=0.5;
10
9
constpercentage=`${decimalNumber*100}%`;
11
10
12
11
returnpercentage;
13
-
}
14
12
15
-
console.log(decimalNumber);
16
13
17
-
// =============> write your explanation here
14
+
// we already have a parameter "decimalNumber" which has been declared in the function. declaring it again with constant is going to give syntax error.
15
+
// Also the console.log is trying to print "decimalNumber" which only exist in a function that is outside its scope.=============> write your explanation here
18
16
19
17
// Finally, correct the code to fix the problem
20
-
// =============> write your new code here
18
+
19
+
20
+
21
+
functionconvertToPercentage(decimalNumber){
22
+
23
+
constpercentage=`${decimalNumber*100}%`;
24
+
returnpercentage;
25
+
26
+
}
27
+
28
+
console.log(convertToPercentage(0.5));// =============> write your new code here
0 commit comments