File tree Expand file tree Collapse file tree 3 files changed +1
-61
lines changed
Expand file tree Collapse file tree 3 files changed +1
-61
lines changed Original file line number Diff line number Diff line change @@ -9,23 +9,5 @@ function capitalise(str) {
99 return str ;
1010}
1111
12-
1312// =============> write your explanation here
1413// =============> write your new code here
15-
16- ///The error is :
17-
18- let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
19-
20- //str is already a parameter of the function.
21- //Doing let str = ... is like giving it a new name in the same place, which JavaScript does not allow.
22- //we can just use the existing str instead of declaring it again.
23-
24- function capitalise ( str ) {
25-
26- // make the first letter uppercase
27-
28- str = str [ 0 ] . toUpperCase ( ) + str . slice ( 1 ) ;
29-
30- return str ;
31- }
Original file line number Diff line number Diff line change @@ -9,35 +9,12 @@ function convertToPercentage(decimalNumber) {
99 const decimalNumber = 0.5 ;
1010 const percentage = `${ decimalNumber * 100 } %` ;
1111
12- return percentage ; =
12+ return percentage ;
1313}
1414
1515console . log ( decimalNumber ) ;
1616
1717// =============> write your explanation here
1818
19- Answer:
20-
21- The number ( 0.5 ) goes into the function — that’s our decimalNumber .
22-
23- We use that decimalNumber to make a percent .
24-
25- We don’t write const decimalNumber again because we already have it .
26-
27- We return the answer ( like "50 % ").
28-
29- Then we call the function with 0.5 and print what it gives back .
30-
3119// Finally, correct the code to fix the problem
3220// =============> write your new code here
33-
34- function convertToPercentage ( decimalNumber ) {
35-
36- const percentage = `${ decimalNumber * 100 } %` ;
37-
38- return percentage ;
39-
40- }
41-
42- console . log ( convertToPercentage ( 0.5 ) ) ;
43-
Original file line number Diff line number Diff line change 66// =============> write your prediction of the error here
77
88function square ( 3 ) {
9-
109 return num * num ;
1110}
1211
1312// =============> write the error message here
1413
15- SyntaxError: Unexpected number
16-
17-
1814// =============> explain this error message here
1915
20- the function takes the number we give it ( 3 ) and times it by itself .
21-
22- so 3 * 3 = 9.
23-
24- it works now cuz we used num instead of a number in the ( )
25-
26-
2716// Finally, correct the code to fix the problem
2817
2918// =============> write your new code here
3019
31- function square ( num ) {
32-
33- return num * num
34- }
35-
36- console . log ( square ( 3 ) )
37-
38-
3920
You can’t perform that action at this time.
0 commit comments