Title Case a Sentence challenge won't pass

I’ve tested each of the test cases in my function, and each result is identical to the test case result. What is causing this the tests to fail when I run it?

Here’s the code:

function titleCase(str) {
  // regex patterns
  
  
  let eachWordRegex = /(?!'.*')\b[\w']+\b/gi;
  let eachWord = str.match(eachWordRegex);
  let firstLetter = "";
  let otherLetters = "";
  let newArray = [];
  
  for (let i = 0; i < eachWord.length; i++){
   
    firstLetter = eachWord[i].slice(0,1);
    otherLetters = eachWord[i].slice(1);
    newArray.push(firstLetter.toUpperCase() +       otherLetters.toLowerCase());   
  }

let newStr = newArray.join(" ")+"."; 
console.log(newStr);
return newStr;

}

titleCase("sHoRt AnD sToUt");

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

You are not returning the correct string. Your function should only be changing the case of the words in the original string passed to the function. For some reason, you are adding a period (.) at the end of the final string returned. The test strings passed to the function do not have periods at the end of them.