Skip to content

Commit de14732

Browse files
Handle empty string case in capitalise function
Updated the capitalise function to handle empty strings.
1 parent 3d69494 commit de14732

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • Sprint-2/1-key-errors

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function capitalise(str) {
1818
// To fix the error, you can simply remove the let keyword and just assign the new value to str without redeclaring it.
1919

2020
function capitalise(str) {
21-
if (typeof str !== "string") {
21+
if (typeof str !== "string" || str.length === 0) {
2222
return str;
2323
}
2424

0 commit comments

Comments
 (0)