Why doesn´t woks my solution of Basic Algorithm Scripting: Title Case a Sentence?

why my solution doesn´t works Basic Algorithm Scripting: Title Case a Sentence?


function titleCase(str) {
var result = '';
var words = str.split(' ');

for (var i = 0; i < words.length; i++){
  var todoAMin = words[i].toLowerCase();
  var primeraMayus = todoAMin.charAt(0).toUpperCase();
  var remplaza = todoAMin.replace(todoAMin.charAt(0), primeraMayus);
     result += remplaza + ' ';
           
  }
  
  return result;

}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");




Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36.

Challenge: Title Case a Sentence

Link to the challenge:

The first thing that jumps out at me is that you will have a space at the end of your result.

Thanks! I will fix that!

i find this solution:
function titleCase(str) {

var result = ‘’;

var words = str.split(’ ');

for (var i = 0; i < words.length; i++){

var todoAMin = words[i].toLowerCase();

var primeraMayus = todoAMin.charAt(0).toUpperCase();

var remplaza = todoAMin.replace(todoAMin.charAt(0), primeraMayus);

   result += remplaza + ' ';
        

}

var sinFinalSpace = /\s$/;

result = result.replace(sinFinalSpace, "");

return result;

}

THANKS!!!