Creating a JavaScript That Displays Daily Specials

The last part of this activity is to create the JavaScript that will display the days special. It will display a different dish for each day of the week. The daily specials will be decided by you. You can use dishes you have already put on your page, or you can use other foods, as long as it fits the exotic food theme. The daily specials will be found on your home page. You will first need to insert <SCRIPT> tags for the functions that you'll be placing on your page. Insert the following just above the </HEAD> tag in your heading:

<SCRIPT LANGUAGE="JavaScript">
<!---Hide from non-JavaScript browsers

//Stop hiding-->
</SCRIPT>

Within the <SCRIPT> tags you will need to create a new function named DishName with a single parameter, Day. Copy the script as shown below between the <SCRIPT> tags and above the stop hiding command.

function DishName (Day)

Within the DishName function, you must create an array variable named DName. Populate the array with the names of the nightly dish specials, where "Monday's Dish Name" will be replaced by the name of your Monday's Special. Place the first curly bracket right behind the function you pasted above, and place the remaining script below the function statement: function DishName (Day) {

{
var DName = new Array();
DName[1]="Monday's Dish Name";
DName[2]="Tuesday's Dish Name";
DName[3]="Wednesday's Dish Name";
DName[4]="Thursday's Dish Name";
DName[5]="Friday's Dish Name";
DName[6]="Saturday's Dish Name";
DName[7]="Sunday's Name";
var IndexNumber = Day;
var food = DName [Day];
return food;
}

Below the DishName function and array, you will insert another function named DishDesc that contains a single parameter Day. Place this function under the closing bracket of the DishName function, just above the stop hiding command.

function DishDesc (Day)

Within the DishDesc function, you must create an array variable named DDesc. Populate the array with the descriptions of the nightly dish specials, where "Monday's Dish Description" will be replaced by the description of your Monday's Special. Place the first curly bracket right behind the function you pasted above, and place the remaining script below the function statement: function DishDesc (Day) {

{
var DDesc = new Array();
DDesc[1]="Monday's Dish Description";
DDesc[2]="Tuesday's Dish Description";
DDesc[3]="Wednesday's Dish Description";
DDesc[4]="Thursday's Dish Description";
DDesc[5]="Friday's Dish Description";
DDesc[6]="Saturday's Description";
DDesc[7]="Sunday's Description";
var IndexNumber = Day;
var list = DDesc [Day];
return list;
return DDesc[Day];
}