Title Case a Sentence why ho why

Title Case a Sentence why ho why
0.0 0

#1

This code works fine but does not pass any tests? exp the first one returning a string:sunglasses:

Your code so far

// make 2 var lowercase split and strVal     
    var strHolder = str.toLowerCase().split(" ");
    var strVal = "";
// loop for iteration    
    for(var i =0; i <= strHolder.length-1; i++){
// upper case fisrt element and slice in the rest add white space       
        strVal += strHolder[i][0].toUpperCase();
        strVal += strHolder[i].slice(1);
        strVal += " ";
    }
    return strVal;
  }
  
  //titleCase("I'm a little tea pot");
  //titleCase("sHoRt AnD sToUt");
  titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");  

Your browser information:

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

Link to the challenge:


#2

You are adding a space at the end of your string.