Skip to content

Commit d6fd51e

Browse files
committed
Handle empty strings in capitalise function
1 parent ebea776 commit d6fd51e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ capitalise("hello");*/
1414
The function stops before it can run. */
1515
// =============> write your new code here
1616
function capitalise(str) {
17+
if (str === "") {
18+
return "";
19+
}
20+
1721
const result = `${str[0].toUpperCase()}${str.slice(1)}`;
1822
return result;
1923
}
20-
capitalise("hello");
21-
console.log(capitalise("hello"));
24+
25+
console.log(`Result: "${capitalise("")}"`);

0 commit comments

Comments
 (0)