Title Case a Sentence Challenge Not Passed

hello, folks :grin:

Basic Algorithm Scripting: Title Case a Sentence i’m here at the moment, and solved this challenge. but i stucked when “Run the tests”: 1 passed and 3 not.

following the solution

function titleCase(str) {
  let str1 = "";
  str.split(" ").forEach(e => {
      str1 += e[0].toUpperCase() + e.slice(1).toLowerCase() + " ";
  });
  return str1;
}

why it’s doesnt pass?

Thank you :+1:

You’re removing all the spaces.

i try debug, but worked.

console.log(titleCase("бабушка курит трубку")); // Бабушка Курит Трубку 
console.log(titleCase("sHoRt AnD sToUt")); //Short And Stout 
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")); //Here Is My Handle Here Is My Spout

Agh sorry, was on phone and it cut off the addition of the space. You’re adding a space to the end of every sentence

The return value of that is "Short And Stout " not "Short And Stout"

1 Like

oh God :man_facepalming:
space damn :rofl: :rofl:

just realized. thank you very much @DanCouper :+1: :+1:

2 Likes