script.js 332 B

12345678910111213141516171819
  1. function clickCounter(elem){
  2. elem.onclick = clickCounter();
  3. let counter = 0;
  4. function clickCounter(){
  5. return function() {
  6. elem.innerHTML = `${counter}`;
  7. console.log(counter)
  8. return counter++;
  9. };
  10. }
  11. };
  12. clickCounter(button1);
  13. clickCounter(button2);