Basic Algorithm Scripting: Title Case a Sentence - my solution is wrong

why this solution is wrong in FCC?
I don’t speak english

function titleCase(str) {
  var fraseInicial = str.toLowerCase();
  var arr = fraseInicial.split(" ");
  var fraseFinal = "";
  arr.forEach(function(element) {  
    var palabra = element.charAt(0).toUpperCase()+element.substring(1,)+" "  ;
    fraseFinal = fraseFinal + palabra;
  str = fraseFinal.trim() + ".";
  return str;

I suggest you to attach a link to the exercise. Also please format your code for readability.

Select your code and click on this </> icon to format the code.

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 easier to read.

Note: Backticks are not single quotes.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.