Skip to content

Commit 71235b3

Browse files
committed
solve the code error message
1 parent c1f0514 commit 71235b3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • Sprint-2/1-key-errors

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
4-
// call the function capitalise with a string input
3+
// Well, I think the variable "str" is being declared twice, so the code will
4+
// through an error message.
5+
//
6+
//call the function capitalise with a string input
57
// interpret the error message and figure out why an error is occurring
68

79
function capitalise(str) {
@@ -10,4 +12,12 @@ function capitalise(str) {
1012
}
1113

1214
// =============> write your explanation here
15+
//The variable "str" has been used as a parameter for the capitalise function
16+
//and also been declared again inside the function. I think if "let" is removed
17+
//the code will work.
1318
// =============> write your new code here
19+
function capitalise(str) {
20+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
21+
return str;
22+
}
23+
console.log(capitalise("sorted"));

0 commit comments

Comments
 (0)