how to make a button do different functions on different clicks code example

Example 1: how to make a button do different functions on different clicks

<button id="clickme">Click Me</button>
<script>
  function one() {
     alert('one clicked');
     document.getElementById('clickme').onclick = two;
  }

  function two() {
   alert('two clicked');
  }

  document.getElementById('clickme').onclick = one;
</script>

Example 2: how to make a button do different functions on different clicks

var callOne = true;

function one() {
   alert('Call one');
}

function two() {
   alert('Call two');
}

function call(){
   if(callOne) one();
  else two();
  callOne = !callOne;
}

Example 3: how to make a button do different functions on different clicks

var fn3 = (function() {
  var first = true;
  return function() {
    first ? fn1() : fn2();
    first = !first;
  }
})();

function fn1() {
  console.log(1);
};
function fn2() {
  console.log(2);
};