WDV221 Intro Javascript

Variables and Data Types - Variables Assignment


Please complete the following exercises on this page. When complete post this page to your server. Make a link in your WDV221 homework page for this assignment.

Include a comment in each script with the exercise number and a description of what the script is supposed to do.

Using Blackboard submit this Assignment.

For each exercise use a comment line to put the Exercise number within the script. Also place a short description of what the script is doing.


1. Define four global variables called color1 through color4. Assign the variables a color.

2. Create a function called getColor( ). Create a local variable called color5.

3. In the getColor( ) use the prompt( ) to ask the user for a color. Store this value in the color5 variable. Use a button with an onclick event handler to activate this function.

4. Create a function called displayColors( ). Use the alert( ) to display all the color variables and their associated value. Use a button with an onclick event handler to activate this function.

5. In your comments address why color5 cannot be displayed by the displayColors( ) function.

ReleaseTheMcCracken