Skip to content

Instantly share code, notes, and snippets.

@boweihan
Created October 15, 2020 03:09
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 boweihan/a40e2b8f61024dba7e7f2d60916b5b9c to your computer and use it in GitHub Desktop.
Save boweihan/a40e2b8f61024dba7e7f2d60916b5b9c to your computer and use it in GitHub Desktop.
imperative programming
const button = document.createElement(`button`);
button.onclick = function(event) {
// WHAT'S THE STATE AGAIN?
if (this.classList.contains(`black`)) {
this.classList.remove(`black`);
this.classList.add(`white`);
} else {
this.classList.remove(`white`);
this.classList.add(`black`);
}
};
document.appendChild(button);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment