April 23, 2019
Javascript Challenge #4: TitleCase
This is another challenge where you have to capitalize first letter of each word in a string. I hope you will enjoy this javascript challenge.
1 2 3 4 5 6 7 8 |
const myMsg = 'This is my string and please Capitalize first letter of every word in it'; function titleCase(msg){ return msg.split(' ').map(word => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase()).join(' ');; } console.log(titleCase(myMsg)); |