Quantcast
Channel: freeCodeCamp Challenge Guide: Title Case a Sentence
Viewing all articles
Browse latest Browse all 50

freeCodeCamp Challenge Guide: Title Case a Sentence

$
0
0

@mazzaroth808 wrote:

                                MY SOLUTION
titleCase(Str) {
    
     var oldArr = str.toLowerCase().split(' ');
     var newArr = [];
     
     for (var i in oldArr) {
         var newWord = oldArr[i][0].toUpperCase() + oldArr[i].slice(1);
         newArr.push(newWord);
        }
     return newArr.join(' ');
}

there’s no need for:

for (var i = 0; i < oldArr.length; i++) {
}

because:

for (var i in oldArr) {
}

will loop through the entire length of oldArr without the need of a loop counter.

Read full topic


Viewing all articles
Browse latest Browse all 50

Trending Articles


FORECLOSURE OF REAL ESTATE MORTGAGE


Maganda Quotes – tagalog Quotes – Inggit Quotes


Pokemon para colorear


Sapos para colorear


Tiwala Quotes and Selos Quotes Collections


Love with Heart Breaking Quotes


RE: Mutton Pies (frankie241)


Hato lada ym dei namar ka jingpyrshah jong U JJM Nichols Roy (Bah Joy) ngin...


EASY COME, EASY GO


UPDATE SC IDOL: TWO BECOME ONE


Smile Quotes


KASAMBAHAY BILL IN THE HOUSE


Girasoles para colorear


Presence Quotes – Positive Quotes


Long Distance Relationship Tagalog Love Quotes


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.


FORTUITOUS EVENT