WDV221 Intro Javascript

Unit-3 - Functions and the String Object



1. Define a global variable called inName. Assign it an initial value of "".

2. Define a global variable called emailAddress and assign it the value of your DMACC email address.

NOTE: These variables should be available to any script on this page including within any functions since they have global scope.

3. Create a function called getName( ). The function will use a prompt to ask the user to enter a name. Store the result in the inName variable. Create a button with an onclick event handler to activate this function.

4. Create a function called displayName( ). The function will use alert( ) to display the value stored in the inName variable. Create a button with an onclick event handler to activate this function.

5. Create a function called getEmail( ). The function will use a prompt( ) to ask the user to input an email address. Store the input in the global variable emailAddress. Create a button with an onclick event handler to activate this function.

6. Create a function called displayEmailName( ). The function will display the name portion of the email address stored in the yourEmailAddress variable. Create a button with an onclick event handler to activate this function.

For example: Assign emailAddress variable a value of "aStudent@dmacc.edu". This function should return display "aStudent".

7. Create a function called displayEmailServer( ). The function will display the email server name after the @ symbol. Create a button with an onclick event handler to activate this function.

For example: Given the same value for emailAddress variable. This function should display "dmacc.edu". Do not include the @ symbol.