/** Class for text layouts. */
class TextLayout {
/**
* Capitalize the first letter of each word in a sentence, that is not contained in the exception list. Useful for headlines.
* @param {string} sentence
* @param {string[]} exceptions
* @returns {string} Sentence with capitalized first letter.
*/
static capitalizeFirstLetter(sentence, exceptions = ['and', 'or', 'nor', 'but', 'at', 'by', 'for', 'in', 'of', 'on', 'a', 'an', 'the']) {
return sentence.replace(/\w*/g, (word) => {
if (exceptions.includes(word))
return word;
return word.charAt(0).toUpperCase() + word.substring(1).toLowerCase();
});
}
}