Word Count Tool

66.8% 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.


  1. Create a click event listener for #countButton
  2. When #countButton is clicked get the text from the textarea element and count the words
  3. Display the number given in the #wordCount span element


  1. Example #1

This is a test

should return 4 as the word count

  1. 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.