I thought I understood closures well with Javascript, but apparently I don't. The following code doesn't work. How do I get it to print out all the numbers from 0 through 9 in the console after a 1 second delay? Currently it just prints "undefined" ten times.

NOTE: I'm not looking for a simpler workout to printing out numbers after a delay. This question is about understanding closures. 

```
<script>
for(var i=0;i<10;i++){
    setTimeout(function(i){console.log(i)}, 1000)
}
</script>

```