The output is totally fine, but the test fails except the return string one.
function titleCase(str) {
const strArr =str.split(" ")
let strOut =""
for (let ele of strArr){
strOut +=`${ele[0].toUpperCase()}${ele.slice(1).toLowerCase()} `
}
return strOut
}
console.log(titleCase("I'm a little tea pot"));
console.log(titleCase("sHoRt AnD sToUt"));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Title Case a Sentence
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.