This question is taken from the first question in the accepted answer here: <https://stackoverflow.com/questions/1684917/what-questions-should-a-javascript-programmer-be-able-to-answer>

```
<a href="#">text</a><br><a href="#">link</a>
 <script>
 var as = document.getElementsByTagName('a');
 for ( var i = as.length; i--; ) {
    as[i].onclick = function() {
        alert(i);
        return false;
    }
 }
</script>

```

Why do the anchors, when clicked on, alert -1 instead of their respective counter inside of the loop? How can you fix the code so that it does alert the right number? (Hint: closures)