Skip to content

Instantly share code, notes, and snippets.

@fey
Created February 13, 2026 14:45
Show Gist options
  • Select an option

  • Save fey/fe4a34b5dde22f9cbf0ec1c4cd577ad4 to your computer and use it in GitHub Desktop.

Select an option

Save fey/fe4a34b5dde22f9cbf0ec1c4cd577ad4 to your computer and use it in GitHub Desktop.
js_dom_fsm_data
<div id="result">0</div>
<button id="increment">+</button>
<button id="decrement">-</button>
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