title: How can you loop through a variable declaration in javascript
body: <p>So I found myself repeating some of my javascript and was wondering if there is a way that I can assign variables in a loop but with an incremented number at the end.</p>
  
  <p>So this is my repeating code that I want looped:</p>
  
  <pre><code>var $d1 = $(".dot-1");
  var $d2 = $(".dot-2");
  var $d3 = $(".dot-3");
  var $d4 = $(".dot-4");
  var $d5 = $(".dot-5");
  var $d6 = $(".dot-6");
  var $d7 = $(".dot-7");
  var $d8 = $(".dot-8");
  var $d9 = $(".dot-9");
  var $d10 = $(".dot-10");
  var $d11 = $(".dot-11");
  var $d12 = $(".dot-12");
  var $d13 = $(".dot-13");
  var $d14 = $(".dot-14");
  var $d15 = $(".dot-15");
  var $d16 = $(".dot-16");
  var $d17 = $(".dot-17");
  var $d18 = $(".dot-18");
  var $d19 = $(".dot-19");
  var $d20 = $(".dot-20");
  var $d21 = $(".dot-21");
  var $d22 = $(".dot-22");
  var $d23 = $(".dot-23");
  var $d24 = $(".dot-24");
  var $d25 = $(".dot-25");
  var $d26 = $(".dot-26");
  var $d27 = $(".dot-27");
  var $d28 = $(".dot-28");
  var $d29 = $(".dot-29");
  var $d30 = $(".dot-30");
  </code></pre>
  
  <p>As you can see its the same thing but with an incremented number in the variable name and class selector. Is there a way to loop through this?</p>
  
  <p>I also found myself stuck trying to loop through this as well:</p>
  
  <pre><code>$(".stop").click(function() {
      player1.pauseVideo();
      player2.pauseVideo();
      player3.pauseVideo();
      player4.pauseVideo();
  });
  </code></pre>
  
  <p>Again I see a repeating process with the same code just incremented numbers at the end. So I see a potential loop in this case as well.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>For those who are curious on what those .dots are used for it would be something like this.</p>
  
  <pre><code>$d1.click(function(){
      $(".content-1").removeClass("zoomOut").addClass('zoomIn');
  });
  $d2.click(function(){
      $(".content-2").removeClass("zoomOut").addClass('zoomIn');
  });
  $d3.click(function(){
      $(".content-3").removeClass("zoomOut").addClass('zoomIn');
  });
  </code></pre>