Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Created January 1, 2017 11:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidgilbertson/ade3abb362fb2a9dcdd81071a786d61b to your computer and use it in GitHub Desktop.
Save davidgilbertson/ade3abb362fb2a9dcdd81071a786d61b to your computer and use it in GitHub Desktop.
function makeElement(type, text) {
const el = document.createElement(type);
const textNode = document.createTextNode(text);
el.appendChild(textNode);
return el;
}
const h1 = (text) => makeElement(`h1`, text);
// and then
document.body.appendChild(h1(`Hello, world.`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment