Created
October 15, 2020 03:09
-
-
Save boweihan/a40e2b8f61024dba7e7f2d60916b5b9c to your computer and use it in GitHub Desktop.
imperative programming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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