Created
February 13, 2026 14:45
-
-
Save fey/fe4a34b5dde22f9cbf0ec1c4cd577ad4 to your computer and use it in GitHub Desktop.
js_dom_fsm_data
This file contains hidden or 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
| <div id="result">0</div> | |
| <button id="increment">+</button> | |
| <button id="decrement">-</button> |
This file contains hidden or 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
| let state = 0 | |
| const result = document.getElementById('result'); | |
| const process = (newState) => { | |
| state = newState; | |
| result.textContent = newState; | |
| }; | |
| const inc = document.getElementById('increment'); | |
| inc.addEventListener('click', () => process(state + 1)); | |
| const dec = document.getElementById('decrement'); | |
| dec.addEventListener('click', () => process(state - 1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment