Skip to content

Instantly share code, notes, and snippets.

@DrummerHead DrummerHead/memeText.js
Last active Aug 6, 2016

Embed
What would you like to do?
// Use this script on your
// preferred modern browser console
const meme = (text) => {
return [...text.toUpperCase()].reduce((prev, curr, i, ary) => {
return [`${prev[0]}${ary[i]} `, `${prev[1]}\n${ary[i + 1] || ''} `];
}, ['','']).reduce((prev, curr) => prev + curr);
};
const result = meme('Aesthetics');
copy(result); // Text is copied to clipboard
console.log(result);
// A E S T H E T I C S
// E
// S
// T
// H
// E
// T
// I
// C
// S
// The two final spaces are so
// Markdown inserts a final <br>
// (Reddit uses Markdown)
@nicbou

This comment has been minimized.

Copy link

nicbou commented Jul 21, 2016

Here's a much shorter version

t=>[[...t.toUpperCase()].join(' '),...t.toUpperCase().substr(1)].join('\n');
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.