title: potential scope issue with animation and sounds
body: <pre><code>$('#start-button').click(function(){
          if(power === true)
          {
                  $(this).toggleClass('on');
                  if(start === true)
                  {
                      start = false;
                  }
                  else
                  {
                      start = true;
                      alert("hello");
                      while(count &lt; 20)
                      {
                          num = Math.floor(4*Math.random());
                          simon.push(moves[num]);
                          soundNums.push(num);
                          var tempCount = count+1;
                          var start = 0;
                          while(tempCount &gt; 0)
                              {
                                  delayMove(tempCount);
                              }
                          var timeDelay;
                          function delayMove(index) {
                              timeDelay = setTimeout(move(index), 500);
                          }
  
                          function move(index) {
                              $(simon[index]).fadeOut(200).fadeIn(200);
                              (sounds[soundNums[index]]).play();
                              start++;
                              tempCount--;
                          }
  
  
  
                          count++;
                          $("p").text(count); 
                      }
                  }
  }
      });
  </code></pre>
  
  <p>So i moved the functions outside and have things I think mostly correct, only problem is now the setTimeout doesn't work. I was hoping this would fix the issue with closures by moving the counting variable into the delayed function. </p>