aboutsummaryrefslogtreecommitdiffstats
path: root/frontend-vanilla/src/counter.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend-vanilla/src/counter.ts')
-rw-r--r--frontend-vanilla/src/counter.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/frontend-vanilla/src/counter.ts b/frontend-vanilla/src/counter.ts
new file mode 100644
index 0000000..09e5afd
--- /dev/null
+++ b/frontend-vanilla/src/counter.ts
@@ -0,0 +1,9 @@
+export function setupCounter(element: HTMLButtonElement) {
+ let counter = 0
+ const setCounter = (count: number) => {
+ counter = count
+ element.innerHTML = `count is ${counter}`
+ }
+ element.addEventListener('click', () => setCounter(counter + 1))
+ setCounter(0)
+}