Skip to content

Commit d50491c

Browse files
committed
finished my tasks
1 parent 200e06c commit d50491c

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

Sprint-2/1-key-errors/0.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,23 @@ function capitalise(str) {
99
return str;
1010
}
1111

12+
1213
// =============> write your explanation here
1314
// =============> 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+
}

Sprint-2/1-key-errors/1.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,35 @@ function convertToPercentage(decimalNumber) {
99
const decimalNumber = 0.5;
1010
const percentage = `${decimalNumber * 100}%`;
1111

12-
return percentage;
12+
return percentage;=
1313
}
1414

1515
console.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+
1931
// Finally, correct the code to fix the problem
2032
// =============> 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+

Sprint-2/1-key-errors/2.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,34 @@
66
// =============> write your prediction of the error here
77

88
function square(3) {
9+
910
return num * num;
1011
}
1112

1213
// =============> write the error message here
1314

15+
SyntaxError: Unexpected number
16+
17+
1418
// =============> explain this error message here
1519

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+
1627
// Finally, correct the code to fix the problem
1728

1829
// =============> write your new code here
1930

31+
function square(num){
32+
33+
return num * num
34+
}
35+
36+
console.log(square(3))
37+
38+
2039

0 commit comments

Comments
 (0)