Skip to content

Instantly share code, notes, and snippets.

@mrobinson537
Created October 31, 2013 17:03
Show Gist options
  • Save mrobinson537/7253271 to your computer and use it in GitHub Desktop.
Save mrobinson537/7253271 to your computer and use it in GitHub Desktop.
Display days of the week using Array's and For loops in Javascript...
var days = new Array();
days[0] = "Sun";
days[1] = "Mon";
days[2] = "Tues";
days[3] = "Wed";
days[4] = "Thur";
days[5] = "Fri";
days[6] = "Sat";
// Second way you could do this
var days2 = new Array("Sun","Mon","Tues","Wed","thurs","Fri","Sat");
alert(days.length);
for (i=0;i<days.length;i++)
{
//document.write("Day" + i + "=" + days[i] + "</br>")
document.write("<h1>" + days[i] + "</h1>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment