Basic Algorithm Scripting - Title Case a Sentence

Tell us what’s happening:
Describe your issue in detail here.
output is correct but it isn’t pass test why please explain.

  **Your code so far**
function titleCase(str) {
let myStr = str.split(' ')
let myNewStr = ''
myStr.forEach(item => {
myNewStr += item[0].toUpperCase() + item.slice(1).toLowerCase() + " ";
return myNewStr;

titleCase("sHoRt AnD sToUt");
  **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:

maybe it’s not correct if it doesn’t accept the output!
let’s check!


here you can see them lined up:

     output: 'Short And Stout ',
   expected: 'Short And Stout'

do you see the difference?

1 Like

forgot to trim();

 return myNewStr.trim();

Thank you.

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