Tell us what’s happening:
The answers are coming out correct but it is showing 4"I’m A Little Tea Pot" in console before the short and stout i do not know why it is incorrect. any help would be appreciated
Your code so far
function titleCase(str) {
let answer = "";
let arr = str.split(" ");
for(let i = 0; i < arr.length; i++){
answer += arr[i].charAt(0).toUpperCase() + arr[i].slice(1).toLowerCase() + " ";
}
console.log(answer);
return answer;
}
titleCase("I'm a little tea pot");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Challenge: Title Case a Sentence
Link to the challenge: