title: How to pass an index to an addEventListener
body: <p>I am using an event listener on a checkbox and I need to be able to pass in an index. Currently it is always saving the index as 2. The length of the groups array is 2.</p>
  
  <pre><code>for(var i = 0; i &lt; groups.length; i++) {
      var input1 = document.createElement('input');
      input1.type = "checkbox";
      input1.addEventListener('click', function () {
          console.log(i);
      }, false);
  }
  </code></pre>