Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 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 }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You canโ€™t perform that action at this time.