WDV221 Intro JavaScript

JavaScript Objects - String and Date Objects

String Object Assignment:

Email Address:
Username:
Domain Name:

String Instructions:

  1. All the functions will use the email input into the form. The field cannot be blank and must be formatted as a valid email address.
  2. Create a function that will display the email address on the Email Address: line. Call this function with the Display Email Address button.
  3. Create a function that will display just the username portion of the email address on the Username: line. Call this function with the Display UserName button. Example student@dmacc.edu will display 'student'.
  4. Create a function that will display just the domain name portion of the mail address on the Domain Name: line. Call this function with the Display Domain name button. Using the above example will display 'dmacc.edu'.
  5. If the email address has a top level domain of .edu change the Domain Name display to a light blue background.
  6. The "Enter New Email" button should return the form and the display fields to their original values.

Date Object Assignment:

Today is:

Date Instructions:

1. Create a function called formatMMDDYYYY(inputDate)

  1. the function will accept an input parameter that is a date object
  2. use the methods of the Date object to get the month, date and year from the input date object
  3. concatenate the pieces together to format the string mm/dd/yyyy
  4. return the formatted string

Display todays date next to the Todays Date button using the formatMMDDYYYY().

The Reset Date Examples should call a function to clear the date examples.

2. Create a function called friendlyDate(inputDate)

  1. the function will accept a date object as input
  2. it will produce and return a string formatted like "Saturday December 18, 2023"

Display todays date when you click the Friendly Date button using the friendlyDate().

3. Create a JavaScript function that will always display the current year in the Copyright statement of the footer.