Build a poll! Three options collect votes, and the component keeps a running tally, a total and a live leader.
The options are Apex, LWC and Flow, in that order, and every tally starts at zero.
For each option render a <button class="vote"> carrying data-name set to that option's name, with the text Vote followed by the name, and a <span class="count"> carrying the same data-name and holding just the number of votes that option has received. Clicking a vote button adds one vote to that option and to no other.
Render a <p class="total"> whose text is exactly Total votes: followed by the sum of every tally.
Finally render a <p class="leader"> holding the name of the option with the most votes. While nobody has voted the leader reads None, and when two options are tied the one listed first wins.
Examples:
Initial render:
<button class="vote" data-name="Apex">Vote Apex</button>
<span class="count" data-name="Apex">0</span>
<button class="vote" data-name="LWC">Vote LWC</button>
<span class="count" data-name="LWC">0</span>
<button class="vote" data-name="Flow">Vote Flow</button>
<span class="count" data-name="Flow">0</span>
<p class="total">Total votes: 0</p>
<p class="leader">None</p>
Click Vote LWC -> the counts read 0, 1, 0
Click Vote Apex twice
and Vote Flow once -> <p class="total">Total votes: 3</p>
Click Vote Flow twice
and Vote Apex once -> <p class="leader">Flow</p>