File tree Expand file tree Collapse file tree 4 files changed +28
-14
lines changed
Expand file tree Collapse file tree 4 files changed +28
-14
lines changed Original file line number Diff line number Diff line change 44// call the function capitalise with a string input
55// interpret the error message and figure out why an error is occurring
66
7- function capitalise ( str ) {
8- let str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
9- return str ;
10- }
7+ // function capitalise(str) {
8+ // let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+ // return str;
10+ // }
1111
1212// =============> write your explanation here
1313// =============> write your new code here
14+ function capitalise ( str ) {
15+ return `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
16+ }
17+
18+ console . log ( capitalise ( "hello" ) ) ;
Original file line number Diff line number Diff line change 55
66// Try playing computer with the example to work out what is going on
77
8- function convertToPercentage ( decimalNumber ) {
9- const decimalNumber = 0.5 ;
10- const percentage = `${ decimalNumber * 100 } %` ;
8+ // function convertToPercentage(decimalNumber) {
9+ // const decimalNumber = 0.5;
10+ // const percentage = `${decimalNumber * 100}%`;
1111
12- return percentage ;
13- }
12+ // return percentage;
13+ // }
1414
15- console . log ( decimalNumber ) ;
15+ // console.log(decimalNumber);
1616
1717// =============> write your explanation here
1818
1919// Finally, correct the code to fix the problem
2020// =============> write your new code here
21+ function convertToPercentage ( decimalNumber ) {
22+ const percentage = `${ decimalNumber * 100 } %` ;
23+ return percentage ;
24+ }
25+
26+ console . log ( convertToPercentage ( 0.5 ) ) ;
Original file line number Diff line number Diff line change 55// =============> write your prediction of the error here
66// SyntaxError: Unexpected number
77
8- function square ( 3 ) {
9- return num * num ;
10- }
8+ // function square(3) {
9+ // return num * num;
10+ // }
1111
1212// =============> write the error message here
1313// SyntaxError: Unexpected number
@@ -25,4 +25,5 @@ function square(num) {
2525 return num * num ;
2626}
2727
28- console . log ( square ( 3 ) ) ;
28+ console . log ( square ( 3 ) ) ;
29+
Original file line number Diff line number Diff line change @@ -97,3 +97,5 @@ console.log(square(3));
9797
9898
9999
100+
101+
You can’t perform that action at this time.
0 commit comments