Title Case Sentence challenge

Please, I need help , take look to my code tell me what’s wrong.

function capitalFirstLetter(a)	{
var i=0; 
var string;
var result="";
var newArray=[];
var finalSentence;
  	                  string = a.toLowerCase();  
                           var myArray =string.split();
 			   var arrayLength= myArray.lenght;

  for ( i<arrayLength; i++;  ) {	
result=myArray[i].charAt(i).toUpperCase() + myArray[i].slice(1);
 finalSentence =join().push(result);

     return finalSentence;

There are a few problems here. To start string is a reserved word. Use another variable name. 2nd .split() requires a separator. (ie. .split(" ")). Also. myArray.lenght length is spelled wrong. Start with that and see how much that helps to start.

Besides the things @pompan129 pointed out, you should also have a look at the for loop.

I would suggest to place the var i = 0 inside the for loop: for(var i = 0; i < arrayLength; i++). You can declare the variable outside of the for loop, but then you should use: for(; i < arrayLength; i++), note the semi-colon directly after the first parenthesis. Also, there should be no semi-colon after i++.


Hello friends

i completed the challenge but i i dont know why he page dont let me go through.

here i let my code. I was 6 hours trying to find the code, i had to do a lot of research in internet, but i did it, sadly the web site dont let me go forward. i need some help. I made the code in Sublime Text 3

function titleCase (str) {
var minusculas = str.toLowerCase(); /Conversion de todas las palabras a minusculas/
var palabras = minusculas.split(" "); /* metodo split para separar las palabras de la cadena*/
var oracion = “”

palabras.forEach(function(word, index, array){ /* bucle for Each para iterar sobre las palabras*/

var mayusculas = word.replace(word[0], word[0].toUpperCase());                           /*remplazar con el metodo replace las letras 0 de cada palabra por la letra en mayusculas */
oracion = oracion + " " + mayusculas;                                                    /*guardo en una variable cada operacion del bucle*/

}); console.log(oracion)


titleCase(“otro ejercicio mas que hago solo”); /* Llamando a la funcion con los parametros*/