Title Case a Sentence - Not executing even if output is same

Tell us what’s happening:
I have written code like this I’m getting given output but still it is failed to execute. Please check once

Your code so far

function titleCase(str) {
var sentence = str.toLowerCase().split(" ")
for(var i = 0;i < sentence.length;i++){
  sentence[i] = sentence[i][0].toUpperCase()+sentence[i].slice(1);
sentence.join(" ")
return sentence;

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/80.0.3987.163 Safari/537.36.

Challenge: Title Case a Sentence

Link to the challenge:

The join method does not transform the array sentence into a string. It simply returns a string. In other words, return sentence is returning an array of title case strings.

1 Like