JSFiddle - React, Tailwind, and code Playground

HTML

<a id="masochist" href="#">How many times can you click me?</a>

JavaScript

var clickCount = 0, link;
link = document.getElementById('masochist')
link.innerHTML = 'How many times can you click me?';
link.onclick = function(){
  clickCount++;
  link.onclick = function(){ clickCount++; };

  start = new Date();
  while (new Date() - start < 5000) {}
  console.log(clickCount);  // this will always be 1

  setTimeout(function(){
    link.innerHTML = 'You clicked me ' + clickCount + ' times. Ow!';
  }, 0);
};