Skip to content

Commit 7e23fc3

Browse files
author
lintsang
committed
recorrect 2-mandatory-errors/1.js
1 parent 38c371d commit 7e23fc3

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

  • Sprint-1/2-mandatory-errors
  • Sprint-2/1-key-errors

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ age = age + 1;
55

66
//TypeError: Assignment to constant variable.
77
//This error is caused by the wrong reassignment of variable 'age'. It is a constant that cannot be reassigned.
8-
//So the error prompted when the second line code try to reassign the variable value.
8+
//So the error prompted when the second line code try to reassign the variable value.
9+
//In this case, I would use let age instead of const age to assign age and set its value.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> I predict this code will create a function which can capitalise the first letter of a string and keep the second letters to last one the same. This string is stored and return to the function call.
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
@@ -9,5 +9,8 @@ function capitalise(str) {
99
return str;
1010
}
1111

12-
// =============> write your explanation here
13-
// =============> write your new code here
12+
// =============> The error message shows "SyntaxError: Identifier 'str' has already been declared". And it indicated the variable name 'str' at line 8, I think it triggered a syntax error when try to declare 'str' in the function while it is already being defined as a function parameter. So I changed it to 'strStored' in the function and it works.
13+
// =============> function capitalise(str) {
14+
// let strStored = `${str[0].toUpperCase()}${str.slice(1)}`;
15+
// return strStored;
16+
//}

0 commit comments

Comments
 (0)