Title Case a Sentence not validated

Title Case a Sentence not validated
0

#1

Tell us what’s happening:
I have checked the code in a browser and it looks good, but not able to pass through the test, can you please help if there is something wrong in the code.

Your code so far

function titleCase(str) {
  
  var tokens = str.split(' ');
  var outputTokens = tokens.map(function (eachToken) {
    return eachToken.slice(0, 1).toUpperCase() + eachToken.slice(1).toLowerCase();
  });
  var output = outputTokens.join(' ');
  console.log("Output : " + output);
  
  return str;
}

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

Link to the challenge:


#2

You are going to kick yourself when you see what’s wrong. Look at your return statement. Is that the variable you want to return?


#3

Apologies, for that stupid blunder…
I will check twice before making posting… Sorry for that :disappointed_relieved:


#4

Sometimes we look at code so long for an logic issue, that we overlook the obvious (a typo). This happens to everyone at some point.