Help With title case Challenge


function titleCase(str) {
  var arr=str.toLowerCase().split(" ");
  for(var i = 0; i<arr.length; i++){
    for(var j =0; j<arr[i].length; j++){
      arr[i][0] = arr[i][0].toUpperCase();
    }
  }
    
  return arr;
}

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

Can you help explain why this code doesn’t work and how i can correct it.

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums