title: jQuery word frequency counter
body: <p>I've fried my brain looking at this for too long.  With the following little JavaScript: </p>
  
  <pre><code> var words = 'one two three four one two three';
          wordArray = words.split(' ');
          var newArray = [];
          var words = {};
          words.word;
          words.count;
          $.each(wordArray, function (ix, val) {
              if ($.inArray(wordArray[ix], newArray) &gt; -1) {
                  newArray[wordArray[ix]].count++;
              }
              else {
                  console.log('that wasnt in the array');
                  newArray.push(wordArray[ix]);
                  newArray[wordArray[ix]].count = 1;
              }
  
          });
  </code></pre>
  
  <p>I get the error <code>cannot set property 'count' of undefined</code>. Why can't I dynamically add the property and have anything work fine?</p>