Skip to content

Commit 24548db

Browse files
committed
Add refactored capitalise function to remove variable declaration conflict
1 parent 5433734 commit 24548db

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
// To fix this error, I could either give the variable a different name or reassign the parameter 'str' without 'let', since no new declaration is made
1818

1919
// =============> write your new code here
20+
// function capitalise(str) {
21+
// let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`;
22+
// return capitalised;
23+
// }
24+
// console.log(capitalise("moses"));
25+
// |
2026
function capitalise(str) {
21-
let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`;
22-
return capitalised;
27+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
28+
return str;
2329
}
2430
console.log(capitalise("moses"));

0 commit comments

Comments
 (0)