title: 1-Min Countdown Javascript
body: <p>I'm attempting to build a typing test that begins counting down when the user presses a key in the text area. I thought an if-else loop would help display and start the 1-minute countdown timer in my HTML but that's not the case. </p>
  
  <p>Please explain to me what I'm doing wrong &amp; how to correct my code.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="timer"&gt;&lt;/div&gt;
  &lt;p&gt;Text for typing test will go here.&lt;/p&gt;
  &lt;textarea id="textarea" rows="14" cols="150" placeholder="Start typing here..."&gt;
  &lt;/textarea&gt;`
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>var seconds=1000 * 60; //1000 = 1 second in JS
  var min = seconds * 60;
  var textarea = document.getElementById("textarea").onkeypress = function() { 
      myFunction()
  };
  //When a key is pressed in the text area, update the timer using myFunction
  
  function myFunction() {
     document.getElementById("timer").innerHTML = 
       if (seconds&gt;=0) {
           seconds = seconds--;
       } else {
           clearInterval("timer");
           alert("You type X WPM");
       }
  } //If seconds are equal or greater than 0, countdown until 1 minute has passed
  //Else, clear the timer and alert user of how many words they type per minute
  
  document.getElementById("timer").innerHTML="0:" + seconds; 
  </code></pre>