useState
React 424 characters
import React, { useState } from "react"
export default function Counter() {
const [count, setCount] = useState(0)
return (
<>
Count: {count}
<button onClick={() => setCount(0)}>Reset</button>
<button onClick={() => setCount((prevCount) => prevCount - 1)}>-</button>
<button onClick={() => setCount((prevCount) => prevCount + 1)}>+</button>
</>
)
}
Svelte 189 characters (55% less)
<script>
let count = 0
</script>
Count: {count}
<button on:click={() => (count = 0)}>Reset</button>
<button on:click={() => count--}>-</button>
<button on:click={() => count++}>+</button>