Title Case a Sentence[Help]

Tell us what’s happening:
what’s wrong with this code? Both toLowerCase() and toUpperCase() are not working in my code😒

Your code so far

function titleCase(str) {
  let words=str.split(" ");
  for(let i=0;i<words.length;i++){
  return words.join(" ");

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:

you are not assigning the result of your operation to the variables changed e.g
words[i[ = words[i].toLowerCase();

better still…
use an empty string to concactenate the result of your operation.

1 Like