I am a javascript newbie. I am learning and I am trying to get the day of week and write it to the document. I am using an array and switch case.
Check my code:
var currentDate=new Date();
var currentDay=currentDate.getDay();
var daysOfWeek=["Sunday","Monday","Tuesday","Wed","Thu","Fri","Sat"];
switch(currentDay){
case 0:
document.write('Today is <b>' +daysOfWeek[0]);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
default:
break;
}
It's working fine but I need to know whether this the best possible code i can write or if I can improve it.