Tell us what’s happening:
On the console i get the right answer but it will not pass it when i run the code
Your code so far
function titleCase(str) {
str = str.toLowerCase();
let word = str.split(" ");
let res = "";
for (var i = 0; i < word.length; i++)
{
var temp = [];
temp = word[i].split("");
temp[0] = temp[0].toUpperCase();
temp = temp.join("");
res += temp + " ";
}
//console.log(word);
console.log(res);
return res;
}
titleCase("sHoRt AnD sToUt");
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
.
Challenge: Title Case a Sentence
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence