I am making a basic counter that counts down the days, hours, mins, and seconds until a date. I was able to find a tutorial on how to go about making this part. I keep getting an error at line 48 where I type elements[i].innerHTML. It is saying elements is undefined at that point in time. I did some troubleshooting and found elements becomes undefined after the switch statement. Why is this?

```
<html>
<a class="test" name="Christmas"></a>
<a class="test" name="New Year"></a>
<a class="test" name="Halloween"></a>

<script>
// javascript
var elements = document.getElementsByClassName("test");
var text = '';
var target_date = new Date().getTime();
for(var i=0; i<elements.length; i++) {
document.write(elements[i]);
switch(elements[i].name){
case "Christmas": 
target_date = new Date("Dec 25, 2014").getTime();
text = "Time until Christmas: ";
break;
case "New Year":
target_date = new Date("Jan 1, 2015").getTime();
text= "Time until the New Year: ";
break;
case "Halloween":
target_date = new Date("Oct 31, 2014").getTime();
text = "Time until Halloween: ";
break;
}
// variables for time units
var days, hours, minutes, seconds;

// update the tag with id "countdown" every 1 second
setInterval(function () {

// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (target_date - current_date) / 1000;

// do some time calculations
days = parseInt(seconds_left / 86400);
seconds_left = seconds_left % 86400;

hours = parseInt(seconds_left / 3600);
seconds_left = seconds_left % 3600;

minutes = parseInt(seconds_left / 60);
seconds = parseInt(seconds_left % 60);

// format countdown string + set tag value
elements[i].innerHTML = text + days + "d, " + hours + "h, "
+ minutes + "m, " + seconds + "s";  

}, 1000);
}
 </script>
</html>

```

I would like to continue using a switch and for loop to accomplish this task in case I choose to add more dates.