Skip to content

Instantly share code, notes, and snippets.

@DrummerHead
Created January 16, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrummerHead/ff1495237bb654c507ed4b51e4e1d358 to your computer and use it in GitHub Desktop.
Save DrummerHead/ff1495237bb654c507ed4b51e4e1d358 to your computer and use it in GitHub Desktop.
// Clap text generator
// ===================
// ## Function
//
const clapText = (text, { uppercase = false, tight = false } = {}) => {
const space = tight ? '' : ' ';
const newText = uppercase ? text.toUpperCase() : text;
return newText.replace(/\s/g, `${space}๐Ÿ‘${space}`);
}
// ## Usage Examples
//
console.log(clapText('Bright vixens jump; dozy fowl quack. Vexed nymphs go for quick waltz job.'))
// > Bright ๐Ÿ‘ vixens ๐Ÿ‘ jump; ๐Ÿ‘ dozy ๐Ÿ‘ fowl ๐Ÿ‘ quack. ๐Ÿ‘ Vexed ๐Ÿ‘ nymphs ๐Ÿ‘ go ๐Ÿ‘ for ๐Ÿ‘ quick ๐Ÿ‘ waltz ๐Ÿ‘ job.
// ### Passing options
console.log(clapText('Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs.', { uppercase: true }))
// > JUNK ๐Ÿ‘ MTV ๐Ÿ‘ QUIZ ๐Ÿ‘ GRACED ๐Ÿ‘ BY ๐Ÿ‘ FOX ๐Ÿ‘ WHELPS. ๐Ÿ‘ BAWDS ๐Ÿ‘ JOG, ๐Ÿ‘ FLICK ๐Ÿ‘ QUARTZ, ๐Ÿ‘ VEX ๐Ÿ‘ NYMPHS.
console.log(clapText('Hick dwarves jam blitzing foxy quip. Fox dwarves chop my talking quiz job.', { tight: true }))
// > Hick๐Ÿ‘dwarves๐Ÿ‘jam๐Ÿ‘blitzing๐Ÿ‘foxy๐Ÿ‘quip.๐Ÿ‘Fox๐Ÿ‘dwarves๐Ÿ‘chop๐Ÿ‘my๐Ÿ‘talking๐Ÿ‘quiz๐Ÿ‘job.
console.log(clapText('How quickly daft jumping zebras vex. Two driven jocks help fax my big quiz.', { uppercase: true, tight: true }))
// > HOW๐Ÿ‘QUICKLY๐Ÿ‘DAFT๐Ÿ‘JUMPING๐Ÿ‘ZEBRAS๐Ÿ‘VEX.๐Ÿ‘TWO๐Ÿ‘DRIVEN๐Ÿ‘JOCKS๐Ÿ‘HELP๐Ÿ‘FAX๐Ÿ‘MY๐Ÿ‘BIG๐Ÿ‘QUIZ.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment