Build a Title Case Converter

function titleCase(string) {

let firstLetter = string.split(" ");

let result = [];

for (let i = 0; i < firstLetter.length; i++) {

let word = firstLetter\[i\];



let captialized = word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();



result.push(captialized);

}

console.log(result.join(" "));

return string;

}

titleCase(“I’m a little tea pot”);

titleCase(“javaScript is fun”);

titleCase(“sHoRt AnD sToUt”);

titleCase(“HERE IS MY HANDLE HERE IS MY SPOUT”);

titleCase(“I like to code”);

Hi @oreoluwasamuel261,

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

Happy coding!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.