Tell us what’s happening:
Hello dear community,
My code gives a good result apparently, but the test does not pass.
Your code so far
function titleCase(str) {
let arr = str.split(" ");
let string = "";
let lo = "";
for (let i = 0; i < arr.length; i++) {
let lo = "";
let upper = arr[i][0].toUpperCase();
for (let j = 1; j < arr[i].length; j++) {
let lower = arr[i][j].toLowerCase();
lo = lo.concat(lower);
}
let word = upper.concat(lo);
string = string.concat(word, " ");
}
console.log(string);
return string.toString();
}
titleCase("I'm a little tea pot");
console.log("I'm a little tea pot");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0
.
Challenge: Title Case a Sentence
Link to the challenge: