Bonfire: Title Case a Sentence, Difficulty: 1


Return the provided string with the first letter of each word capitalized.

For the purpose of this exercise, you should also capitalize connecting words like ‘the’ and ‘of’.

Remember to use RSAP if you get stuck. Try to pair program. Write your own code.


My Solution:

function titleCase(str) {

var str = str.toLowerCase();
var array = str.split(‘ ‘) ;

for (i = 0; i < array.length; i++){
array[i] = array[i].charAt(0).toUpperCase() + array[i].substring(1);


var arrJoin = array.join(‘ ‘);

return arrJoin;

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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s