Skip to content

Commit 0921c64

Browse files
committed
fix error 0
1 parent d28242a commit 0921c64

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

‎Sprint-3/1-key-errors/0.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============>The function will return capital S because the first letter of the str variable was capitalised with the toUpperCase method
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
6+
// The str identifier has already been declared in the function parameter and cannot be declared anywhere else inside the function as a variable
7+
8+
// =============> write your explanation here
9+
// When a parameter is declared in a function, it causes an Error if it is declared inside the function as a variable, either you change the name used for the instructions or remove let
10+
// =============> write your new code here
611

712
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
13+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
914
return str;
1015
}
1116

12-
// =============> write your explanation here
13-
// =============> write your new code here
17+
console.log(capitalise("hello"));

0 commit comments

Comments
 (0)