JavaScript Strings
//from [1] below
const toTitleCase = (str: string) => {
return str.replace(/\w\S*/g, function (txt: string) {
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
});
};
//string formatting
let soMany = 10;
console.log(`This is ${soMany} times easier!`);
//multi-line string
setMessage(`
Multi-line
string
here.
`);
Articles
- Three Ways to Title Case a Sentence in JavaScript (freecodecamp.org, 2016)
- Convert string to Title Case with JavaScript (stackoverflow.com, 2014) [1]