Basic Algorithm Scripting - Title Case a Sentence

Tell us what’s happening:
Describe your issue in detail here.
I tested it by console.log() to verify it’s output, and all three cases are works, but it still won’t pass, I don’t why.
Your code so far

function titleCase(str) { 
  const strArr=str.split(" ");
  let newStr="";
  for(let i=0 ; i<strArr.length;i++)
    newStr+=strArr[i][0].toUpperCase()+strArr[i].slice(1,strArr[i].length).toLowerCase()+" ";
  return newStr;
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/ Safari/537.36

Challenge: Basic Algorithm Scripting - Title Case a Sentence

Link to the challenge:


Check the output and make sure there are no spaces at the end/start of the string.

Hint: print (console.log) your strings surrounded by quotes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.