Word Count Tool
Easy
64
67.4% Acceptance
In this lab, you have to create a simple word count tool using JavaScript.
The user will input text into a textarea
element, and when they click on the #countButton
, the tool should count the number of words in the input and display the result in a #wordCount
span element.
Steps
- Create a
click
event listener for#countButton
- When
#countButton
is clicked get the text from thetextarea
element and count the words - Display the number given in the
#wordCount
span element
Examples
- Example #1
This is a test
should return 4
as the word count
- Example #2
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
should return 12
as the word count
HINT: Word are first split based on the spaces available and then counted. You can use your own method of counting the words, however the final output should remain the same.