Skip to content

Instantly share code, notes, and snippets.

@hail2u
Created August 12, 2018 10:27
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 hail2u/22df38cd85098a3604bd50b823d7a061 to your computer and use it in GitHub Desktop.
Save hail2u/22df38cd85098a3604bd50b823d7a061 to your computer and use it in GitHub Desktop.
/*!
* heading-break.js
* LICENSE: http://hail2u.mit-license.org/2018
*/
const addWordJoiner = (added, value, index) => {
if (index > 3) {
return `${value}${added}`;
}
return `${value}\u2060${added}`;
};
for (const heading of document.querySelectorAll("main > article > h1")) {
heading.textContent = heading.textContent
.split("")
.reverse()
.reduce(addWordJoiner);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment