title: Unique words counter using javascript
body: <p>I want to make a function uniqueWordCount which can count all unique words in a string (words.txt). I should be able to get the answer after returning it, and I have done something like this now:</p>
  
  <pre><code>let fs = require('fs');
  
  function run() {
    let text = fs.readFileSync('./words.txt', 'utf8');
    return uniqueWordCount(text);
  }
  
  function uniqueWordCount(str) { 
  
    let count = 0;
  
    let set = new Set();
  
    let words = str.split (' ');
  
    for(let i = 1; 1 &lt; words.length; i++){
      set.add(str[i]);
      count = set.size;
    }
  
    return uniqueWordCount;
  }
  
  
  module.exports.run = run; 
  </code></pre>