Skip to content

Commit f9b067e

Browse files
committed
Sprint 2 errors: fix key errors 0-2 and document causes
1 parent 5026ab3 commit f9b067e

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
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"));

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
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));

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
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+

Sprint-2/1-key-errors/answers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ console.log(square(3));
9797

9898

9999

100+
101+

0 commit comments

Comments
 (0)