Skip to content

Commit 457005f

Browse files
committed
1-key-errors 0.js another approach added
1 parent fc6e83d commit 457005f

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ function capitalise(str) {
1818
// =============> write your explanation here
1919
// =============> write your new code here
2020

21+
//First version below, another approach displayed as a working code
22+
23+
// function capitalise(str) {
24+
// str = `${str[0].toUpperCase()}${str.slice(1)}`;
25+
// return str;
26+
// }
27+
2128
function capitalise(str) {
22-
str = `${str[0].toUpperCase()}${str.slice(1)}`;
23-
return str;
29+
const firstLetter = str[0];
30+
const smallStr = str.slice(1);
31+
const upperLetter1 = firstLetter.toUpperCase();
32+
let newStr = upperLetter1 + smallStr;
33+
return newStr;
2434
}

0 commit comments

Comments
 (0)