Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<!DOCTYPE html><html><body style="padding:20px;font-family:Arial"><p>Counter: <span id="v">0</span></p><button onclick="c.inc();d()">+</button><button onclick="c.dec();d()">-</button><script>function mk(){let n=0;return{inc:()=>++n,dec:()=>--n,val:()=>n};}const c=mk();function d(){document.getElementById("v").textContent=c.val();}</script></body></html>
Result
Open