Skip to content

Commit 0f18c37

Browse files
committed
Editted key errors 0 to match more closely with what was asked
1 parent 0f63b87 commit 0f18c37

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ capitalise("hello world");
77
// Error message: SyntaxError: Identifier 'str' has already been declared. The error is because the variable str has already been declared.
88

99
function capitalise(str) {
10-
let newStr = `${str[0].toUpperCase()}${str.slice(1)}`;
11-
return newStr;
10+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
11+
return str;
1212
}
1313

1414
// =============> I've given the variable a new name, newStr, to avoid redclaring the variable.

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Predict and explain first...
2-
32
// Why will an error occur when this program runs?
4-
// =============> write your prediction here
3+
// =============> The error will be a syntax error because the variable decimalNumber has already been declared as a parameter. The console log is trying to access decimalNumber which is not within its scope.
54

65
// Try playing computer with the example to work out what is going on
76

@@ -14,7 +13,13 @@ function convertToPercentage(decimalNumber) {
1413

1514
console.log(decimalNumber);
1615

17-
// =============> write your explanation here
16+
// =============> I got a syntax error that the variable is already declared.
1817

1918
// Finally, correct the code to fix the problem
2019
// =============> write your new code here
20+
// function convertToPercentage(decimalNumber) {
21+
// const percentage = `${decimalNumber * 100}%`;
22+
// return percentage;
23+
// }
24+
25+
// console.log(convertToPercentage(0.5));

0 commit comments

Comments
 (0)