JSFiddle - React, Tailwind, and code Playground

by mnk

HTML

<button>
 click me!
</button>

JavaScript

const btn = document.querySelector('button')


let i = 0;
let acc = [];
let timer = null;

const handleOnClick = () => {
	acc = [...acc, i++];

  if(!timer) {
  	timer = setTimeout(() => {
    	console.log(acc);
      acc = []
      timer = null;
    }, 1000)
  }
}


btn.addEventListener('click', handleOnClick)