Skip to content

Commit d83f34c

Browse files
Fix capitalise function
1 parent d28242a commit d83f34c

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// I believe this will cause an error because str is declared twice
33

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) {
7+
/* function capitalise(str) {
88
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
99
return str;
1010
}
11+
*/
12+
13+
// The error happens because str is declared twice, once as a parameter & again with let
14+
// If I give the new variable a different name, I hope it should work :)
15+
16+
17+
function capitalise(str) {
18+
let newString = `${str[0].toUpperCase()}${str.slice(1)}`;
19+
return newString;
20+
}
1121

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

0 commit comments

Comments
 (0)