Tell us what’s happening:
I have written a code to convert first letter of a sentence to uppercase. the console log output shows the correct answer but the course says its still wrong. could you please point out what’s wrong with my code here?
Your code so far
function titleCase(str) {
let a = str.split(" ")
let b = ""
for(let i=0;i<a.length;i++){
b = b + " " +a[i].charAt(0).toUpperCase()+a[i].slice(1).toLowerCase()
}
console.log(b)
return b
}
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/121.0.0.0 Safari/537.36 OPR/107.0.0.0
Challenge Information:
Basic Algorithm Scripting - Title Case a Sentence