titleCase Challenge Problem

ESP
Mi codigo parece estar funcionando perfectamente pero por alguna razon no pasa los test. No logro saber qué está mal.
ENG
My solution seems to be working but it doesn´t pass the test.
I don´t really know what is wrong.


var newArr =[]
function titleCase(str) {
let lowerCase =str.toLowerCase();//Sets the string to lowercase 
let arr = lowerCase.split(" ");//Gives you an array from the string
for (let i = 0; i < arr.length; i++){
 let palabra = arr[i];
 let letraMayus = palabra.charAt(0).toUpperCase();
 let newStr = palabra.slice(1);
 newArr.push(letraMayus + newStr);
}
str = newArr.join(" ");
return str;
}
titleCase("I'm a little tea pot");
  **Información de tu navegador:**

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0

Desafío: Haz que la primera letra de una palabra este en mayúscula

Enlaza al desafío:

It looks quite good and it is interesting to read a solution in Spanish, really! First of all, try to put the global var-declaration (first line) into the function and add a “;” at the end. Does this help? (I tried it out and it works for me.)

1 Like

It worked :smiley:
I should definitely keep working in the understanding of the scope for variables.
Thank you very much