Title Case a Sentence error

`Preformatted var mt=" ";
return console.log(mt);
for(var i=0;i<num;i++){
return console.log(mt);

What you are doing would put a set of set of double quotes at the end. You don’t need double quotes though. The reason the tests show quotes to denote that the result is a string.

it still does not pass the test??

Can you post your new code into a reply? Before pasting the code in, you can click the </> button in the editor and then paste your code in to the spot that says “type or paste code here”. This will put the neccessary 3 back-ticks on the lines before and after the code, so that everyone can view the formatted version of your code.

i messed up copy pasting lost the previous code on topic…
will try to rewrite and post agian.

function titleCase(str) {
  var tor=" ";
var temp=str.split(" ");//string to array

for(var i=0; i<temp.length;i++){
// consider "the" at first index in array
var cap=temp[i][0];// Run throught First element of array and save first character "t"

cap=cap.toUpperCase();//Capital first character "T"

var tap=temp[i];// Saving text "the"

tap=tap.slice(1,temp[i].length);//slice first character"he"

tap=tap.toLowerCase();// lower case "he"

tor=tor+(cap+tap+" ");
 /* adding Capitalized character"T"+ lowercases text"he"+adding spaces to next element in loop" space"*/

  return tor;     //the code works and does titled text but still not passing the test???
                                  //can any1 help?

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


It looks like you’re probably adding and extra space at the end.

On all the tests you have an extra space at the beginning and ending of the sentence.

For example:

titleCase("I'm a little tea pot"); // results in ' I\'m A Little Tea Pot '


titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") ; // results in ' Here Is My Handle Here Is My Spout '

how to get rid of those space and how do they generate?/

To get rid of them, you can add .trim() to the end of tor in the return statement.

You generated them when you first declared tor = " "; That was the space on the front end. Also, you were always adding a space at the end of each word with tor=tor+(cap+tap+" "); The final word always had this extra space tacked onto the end.

Thank You! for the same.