title: How to make a click counter for another button function?
body: <p>I made a function that checks if an input number is equal to Math.random(). I want to make another function to check how many times the button was clicked before the user got the correct answer. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function guess() {
    var x = document.getElementById('this').value;
    var y = Math.floor((Math.random() * 10));
  
    if (x == y) {
      alert("Nice");
    } //correct answer
    else if (x &gt; y) {
      alert("Lower");
    } else {
      alert("Higher");
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
    &lt;input type="number" min=1 max=2 id="this"&gt;
    &lt;button type="button" onclick="guess()"&gt;Check&lt;/button&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I expect to see the number of tries the number has done.</p>