Can anyone tell me why I am getting an undefined error, and what I can do to fix it? I appreciate your help.

<script>
		window.onload=myday;
			
			function myday(){
				
			var day=new Array("sunday","monday","tuesday","wednesday","thursday","friday","saturday");
			
			var d=new Date();
			theDay=d.getDay();
			
			for (i=0;i<=day.length;i++)
			{
					if (i!=theDay)
				{
				
				document.write("today is not " + day[i]);
				document.write("<br />");}
				
				else
				{
					document.write("today is " + day[i]);
					document.write("<br />");}
			}
			}
			
			
</script>

line 11 should be "less than day.length" NOT "less than or equal to": for (i=0; i [B]<[/B] day.length; i++)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.