Tell us what’s happening:
My code returns exactly as requested but for the compiler it does not work. Can you tell me what the problem is?
Your code so far
function titleCase(str) {
str = str.toLowerCase();
var array1 = str.split(' ');
var str1="";
console.log(array1);
for(i=0; i<array1.length; i++) {
var array2 = array1[i];
str1 += array2[0].toUpperCase();
for(j=1; j<array2.length;j++) {
str1 += array2[j];
}str1 +=" ";
}
console.log(str1);
str = str1;
return str;
}
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7
.
Link to the challenge:
https://www.freecodecamp.org/challenges/title-case-a-sentence