Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 059923d

Browse files
Minor fix
1 parent c683c1e commit 059923d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎08_capitalize/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
// For each character of the string if the character on the left is space capitalize and add to the result else add it to the result
2222
function capitalize(str) {
2323
let result = str[0].toUpperCase();
24-
for(let i = 1; i <= str.length; i++) {
25-
if(str[i - 1] === ' ') {
24+
25+
for (let i = 1; i < str.length; i++) {
26+
if (str[i - 1] === ' ') {
2627
result += str[i].toUpperCase();
2728
} else {
28-
result += str[i]
29+
result += str[i];
2930
}
3031
}
32+
3133
return result;
3234
}
3335

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /