Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Last active March 8, 2019 01:36
Show Gist options
  • Save MeetMartin/ecf8e0c60c91964f8ee7df772de6345d to your computer and use it in GitHub Desktop.
Save MeetMartin/ecf8e0c60c91964f8ee7df772de6345d to your computer and use it in GitHub Desktop.
class TextTransformation {
static capitalize(text) {
return text.charAt(0).toUpperCase() + text.slice(1);
}
static addExclamationMark(text) {
return text + '!';
}
static addPunctuation(text) {
return text + '.';
}
static makeImportant(text) {
let transformed = text;
transformed = transformed.trim();
transformed = transformed.toLowerCase();
transformed = TextTransformation.capitalize(transformed);
transformed = TextTransformation.addExclamationMark(transformed);
return transformed;
}
static makeUnimportant(text) {
let transformed = text;
transformed = transformed.trim();
transformed = transformed.toLowerCase();
transformed = TextTransformation.addPunctuation(transformed);
return transformed;
}
}
export default TextTransformation;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment