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

Hi there, here is my solution to the problem. Capitalizing the first character of each element of string array ‘str’ then ‘lowercasing’ the other characters in the remainder of each element. Join them all up afterwards…voila!

function titleCase(str) {
str = str.split(’ ');
var strlen = str.length;
var strarr = [];
var strslice = [];

for (var i = 0; i < strlen; i++)
{
strarr[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1).toLowerCase();
}
return strarr.join(" ");
}

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

Read full topic


Viewing all articles
Browse latest Browse all 50

Trending Articles


FORECLOSURE OF REAL ESTATE MORTGAGE


Tinkerbell para colorear, pintar e imprimir


Pokemon para colorear


Jimmy Neutron para colorear


Girasoles para colorear


God Quotes – Motivational Quotes


RE: Mutton Pies (jameskoiman)


Hagibis (1946) by Francisco V. Coching


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


Vimeo 3.18.0 by Vimeo Inc