The output is as needed..still i cannot pass the test

Tell us what’s happening:

Your code so far


function titleCase(str) {
 
  str=str.toLowerCase();
  var arr=[];
  var s="";
  var j=[];
  arr=str.split(" ");
  for(var i=0;i<arr.length;i++)
    {
      
  
     var x= arr[i].charAt(0);
     x= x.toUpperCase();
    arr[i]=setcharAt(arr[i],0,x);
     s=s+arr[i]+" "; 
    }
  s=s.trim();
  var s1='"'+s+'"'+".";
 return s1;
}
function setcharAt(string,index,char)
{
 if(index>string.length-1)
   {
     return string;
   }
  else
    {
      return string.substr(0,index)+char+string.substr(index+1);
    }
}

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

Your browser information:

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

Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence

Not sure what you are trying to do with this code:

var s1='"'+s+'" '+".";

You don’t have to add quotes and a period. The quotes in the tests only indicate that the result should be a string.

:sweat_smile:thanx for the help…it did work!!!