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

Here is what I was able to come up with for my solution using splice.

function titleCase(str) {
var lowerCase = str.toLowerCase();

var wordArray = lowerCase.split(" ");
var newWord = [];
var newLetter = [];
var finalWord = “”;
for (i = 0; i < wordArray.length; i++){
newLetter += wordArray[i][0].toUpperCase();
newWord += wordArray[i].replace(wordArray[i][0], newLetter[i]) + ’ ';

}

newWord = newWord.split(" “);
newWord.splice(-1,1);
console.log(newWord);
finalWord = newWord.join(” ");

return finalWord;
}

titleCase(“I’m a little tea pot”);

Read full topic


Viewing all articles
Browse latest Browse all 50

Trending Articles


Vimeo 10.7.1 by Vimeo.com, Inc.


UPDATE SC IDOL: TWO BECOME ONE


KASAMBAHAY BILL IN THE HOUSE


Girasoles para colorear


Presence Quotes – Positive Quotes


EASY COME, EASY GO


Love with Heart Breaking 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.


FORECLOSURE OF REAL ESTATE MORTGAGE


FORTUITOUS EVENT


Pokemon para colorear


Sapos para colorear


Smile Quotes


Letting Go Quotes


Love Song lyrics that marks your Heart


RE: Mutton Pies (frankie241)


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


Long Distance Relationship Tagalog Love Quotes