Assignment 5 back to main

Deadline: Wednesday, November 21st, 2007, 4:15PM

Write a JavaScript Program to Count the Number of Words and Number of Vowels in a Passage

Requirements

1. Assume there is form with a text area and a button in a HTML page. The name of the text area is "inputtext", and the value of the button is "Count".

2. The button inside the form element has a "onclick" attribute, and it's equal to "count()" which is the name of the JavaScript function you're going to write.

3. User can enter text in the text area and after they finish entering the text, they will click on the "Count" button . This will generate the "onclick" event, and will execute the "count()" function since "onclick" is equal to "count()".

4. So, you need to implement the "count()" function which does following:

  • Counts the number of vowels (a, e, i, o, u) in the text entered by the user and prints out the count of each vowel, either to the HTML page itself or using an alert function.
  • Counts the number of words in the text entered by the user and prints out the count to the HTML page.
  • The definition of a "word" in this case is any series of characters separated by space, comma or period.

5. After you're done, name your JavaScript file with <your name>.js and submit it the "Assignment5" folder under the submission directory. MAKE SURE include your name in file name.

 

 

<back to top>