Programming Puzzle. Build a tool that allows the user to see how many words, sentences, spaces, and average words per sentence are contained within a passage of text

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

HTML

This is what the rendered HTML should look like before a user presses the button.
JavaScript

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)

JavaScript

This is an example of what should show up after the user clicks the button.
Additional

Use of loops, functions, if statements and variables.

Do not use the JavaScript .split() function
Be creative!! Have Fun!!

2 Likes

Well, that was fun, thank for sharing this
Checked it with words and seem to be right for those 1000word essay :smiley:

Not sure how this goes (any discussion on this thread?) but anyway thanks again and good luck to those attempting it :grin:

Looks like a really darn good challenge. It takes several concepts addressed in the algorithm challenges here, but I really like that it says not to use .split() haha. I see people doing algorithm challenges using already made methods, but ideally you should be writing them from scratch completely.

split() wouldn’t help much here anyway. It would break sentence detection in some corner cases.

Could be. Perhaps it’s only being discouraged. Might be enforcing poor problem solving.

Thanks to all the repliers. I am very new to computer coding. I am coming back to it after several years away from it. I first took computer programming in high school. I started self-learning after high school then went in other directions. It seems I have come back around to it. In my mind this means I was meant to do it, but with lots of hard work.