I'd like my code to show me the content of an array when I click on a button.
One click for array[0], second for array[1] etc. I got it, but I don't know how to disable the button (or just stop the function) when my array has run out of content. I tried some simple for loop, but it didn't work.
var writing = (function() {
  var myArray = ["one ", "two ", "three!"];
  var counter = -1;
  return function() {
    return myArray[counter += 1];
  }
})();
function buttonFunction() {
  document.getElementById('parag').innerHTML += writing();
}<button onclick='buttonFunction()'>Click</button>
<p id="parag">...</p> 
     
     
     
     
    