title: Starting timer when clicking first card of memory game
body: <p>Ok I am trying to wrap up a project and the only thing holding me back is it that they call for the timer to start on clicking a match game. The timer starts when the HTML file loads which is not what the project wants and I have tried some methods but ends up freezing the game. I want the timer to be able to start when clicking a card.</p>
  
  <pre><code>var open = [];
  var matched = 0;
  var moveCounter = 0;
  var numStars = 3;
  var timer = {
      seconds: 0,
      minutes: 0,
      clearTime: -1
  };
  
  //Start timer
      var startTimer = function () {
          if (timer.seconds === 59) {
              timer.minutes++;
              timer.seconds = 0;
          } else {
              timer.seconds++;
      };
  
  
      // Ensure that single digit seconds are preceded with a 0
      var formattedSec = "0";
          if (timer.seconds &lt; 10) {
              formattedSec += timer.seconds
          } else {
              formattedSec = String(timer.seconds);
          }
  
          var time = String(timer.minutes) + ":" + formattedSec;
          $(".timer").text(time);
      };
  </code></pre>
  
  <p>This is the code for clicking on a card. I have tried to include a startTimer code into this but doesn't work.</p>
  
  <pre><code>var onClick = function() {
      if (isValid( $(this) )) {
  
          if (open.length === 0) {
              openCard( $(this) );
  
          } else if (open.length === 1) {
              openCard( $(this) );
              moveCounter++;
              updateMoveCounter();
  
              if (checkMatch()) {
                  setTimeout(setMatch, 300);
  
              } else {
                  setTimeout(resetOpen, 700);
  
              }
          }
      }
  };
  </code></pre>
  
  <p>And this class code I use for my HTML file</p>
  
  <pre><code>&lt;span class="timer"&gt;0:00&lt;/span&gt;
  </code></pre>