title: sleep is not defined in async function?
body: <h3>Im currently working on a memory game project. A function I am trying to implement, flips cards around after two seconds instead of having them flip instantly.</h3>
  
  <pre><code>let openCards = [];
  
  function cardActions(card) {
      // prevent function from adding two classes over and over again 
      if (!(card.classList.contains('open'))) {
          // display the card's symbol 
          card.className += ' open';
          card.className += ' show';
          // add card to list of open cards
          openCards.push(card);
          if(openCards.length === 2) {
              if(openCards[0].innerHTML === openCards[1].innerHTML) {
                  // add the match class
                  Array.from(openCards).forEach(function(card){
                      card.className += ' match';
                  });
                  console.log('match');
                  // empty open cards
                  openCards = [];
              } else {
                  Array.from(openCards).forEach(function(card) {
                      // add the mismatch class
                      card.className += ' mismatch';
                  });
  </code></pre>
  
  <blockquote>
    <p>at this point of the program is where I plan to flip the cards back over when the user has already looked at them. </p>
    
    <p>So what I did was create an asyn function called flip. I placed an await sleep inside to pause program execution but all i did was recieve 'sleep is not defined' error. </p>
    
    <p>I am not sure why this is happening since the sleep function IS defined inside the flip function.</p>
  </blockquote>
  
  <pre><code>                // flip cards around
                  async function flip() {
                      await sleep(2000);
                      Array.from(openCards).forEach(function(card) {
                          card.classList.remove('mismatch')
                          card.classList.remove('open');
                          card.classList.remove('show');
                      });
                  }
                  // give user time to look at the cards
                  flip();
                  console.log('these dont match');
                  // empty open cards
                  openCards = [];
              }
          }
      }
  }
  </code></pre>