Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Challenge - Count The Words

Explanation

In the script.js file you will find the whole of Chapter 1 of Dracula by Bram Stoker.

To complete this challenge you should count the number of times a word appears in the chapter of Dracula.

Example Result

Below is an example of how the result should be printed to the console.

For example the input:

"You and me and You"

would produce

{ You: 2, and: 2, me: 1}

Prior knowledge

To complete this exercise you should understand

  • Strings and string manipulation
  • Loops or forEach
  • Comparison inside if statements

How to run the code?

In Visual Studio you can press F5. Alternatively you can use the terminal and write node script.js when you're in the correct file.

Advanced challenges

  1. Remove all of the punctuation (e.g. ".", ",", "!", "?") to tidy up the results

  2. Ignore the case of the words to find more unique words. e.g. (A === a, Hello === hello)

  3. Order the results to find out which word is the most common in the chapter