Title Case a Sentence SOLVED

Title Case a Sentence SOLVED
0.0 0

#1

Tell us what’s happening:
I’m not sure what to do next. I can get the first character of each word uppercase, but now I don’t know how to join the string back together with the uppercase letter. I’ll continue working and update if I get it.

Your code so far

function titleCase(str) {
  var a;
  a = str.toLowerCase().split(' '); //makes the string lowercase and splits it up
  for (i=0; i<a.length; i++) {  //goes through each word
    a[i] = a[i].charAt(0).toUpperCase() + a[i].slice(1);
  }
  return a.join(" ");
}

titleCase("I'm a little tea pot");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


#2

I suggest reviewing Concatenating Strings with the Plus Operator


#3

Updated question, any suggestions?


#4

If you’re trying to get your words from an array into a string, look into the join() function.


#5

A buddy helped me get this one figured out, thanks for the help.