Requirements
HTML
- Include an area for users to enter text
- Include a button that a user can click to trigger the analysis of the input text
- Include 4 paragraph elements that will be used to display the calculated stats
This is what the rendered HTML should look like before a user presses the button.
Java Script
When the button is clicked, do the following:
- Assign the value of the text area input to a variable
- Loop over the input and keep track of the
- total number of words (Hint: How do you know when there is a new word?)
- total number of sentences (Hint: How do you know when a sentence ends?)
- average words per sentence
- total number of spaces
- Change the text of the 4 paragraph elements to display these four calculated stats. (Hint: innerHTML)
Hello world! This is my Coding from Scratch final project. It's pretty cool, isn't it? |
There are an average of 5 ,words per sentence.
There are 14 spaces in this text..
There are 15 ,words in this text.
There are 3 sentences in this text.
This is an example of what should show up after the user clicks the button.