WDV221 Intro Javascript

Unit-3 - Functions

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.

Submit this assignment on Blackboard. Please include a link to your homework page.

Use Javascript to complete the following tasks.

  1. Create a global variable and assign it with a string of your name
  2. Create a function called sayHello( ). The function will use the alert( ) function to display your name. Call it during runtime.
  3. Create a function called printHello( ). The function will use the document.write( ) function to display your name. Call it twice in a row during runtime.
  4. Call the printHello( ) function so that it prints your name inside of an h1 element.
  5. Create a function called characterCount( ).
    1. Create a local variable called testString.
    2. Use the prompt( ) to ask for a string. Store the result in the testString variable.
    3. Use the String.length property to get the number of characters in the variable.
    4. Display the results using an alert( ).
    5. Call this function using an event handler such as onclick.