I have ordered list in Html:
<ol id="myList">
  <li>Tea</li>
  <li>Milk</li>
  <li>Water</li>
</ol>
<button onclick="myFunction()">Try it</button>
and this is Javascript code, to create new object in this list:
<script>
function myFunction() {
    var x = document.createElement("li");
    var t = document.createTextNode("Coffee");
    x.appendChild(t);
    document.getElementById("myList").appendChild(x);
}
</script>
but everytime when I click "Try it" I can create new item in list, but I want to have a limit of 1 or 2. When user clicks on button, he should be able to create only one extra item. How can I do this?
 
     
     
    