I am having some trouble figuring this out. I would like to loop through all the months once, instead of twelve times as my code is doing so now. Can anyone help, also is there a more effective way of looping this funciton?
Thanks!
window.onload = function() {
getMonth();
};
function getMonth()
{
var x="",i=0;
var month=Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
while (i<12)
{
x=x + month + "<br/>";
i++;
}
document.getElementById("months").innerHTML=x;
}
here is a link to my jsfiddle demo http://jsfiddle.net/priswiz/LqEE6/
month[i]fiddle