title: Eloquent JavaScript: The Lycanthrope's Log, table values?
body: <p>I am working on eloquent javascript at the lycanthrope's log, I can't seem to understand, I've been checking values and testing on console.log but I cant seem to get this code: </p>
  
  <pre><code>var JOURNAL = [
    {"events":["carrot","exercise","weekend"],"squirrel":false},
    {"events":["bread","pudding","brushed teeth","weekend","touched tree"],"squirrel":false},
    {"events":["carrot","nachos","brushed teeth","cycling","weekend"],"squirrel":false},
    // ...
  ]
  
  function hasEvent(event, entry) {
    return entry.events.indexOf(event) != -1; // check if event occured / not  false
  }
  
  function tableFor(event, journal) {
    var table = [0, 0, 0, 0];
    for (var i = 0; i &lt; journal.length; i++) {
     var entry = journal[i], index = 0;
  
     if (hasEvent(event, entry)) index += 1; // if pizza occured, add+1 on table index
      //object of arrays --&gt; console.log(entry); 
     if (entry.squirrel) index += 2; // if squirrel is true, add+2 on index
     table[index] += 1; //&lt;-- I don't understand this 
     // console.log(index);
    }
   return table;
  }
  
  console.log(tableFor("pizza", JOURNAL));
  // I don't understand how values are added here, 
  // how did this become→ [76, 9, 4, 1]
  </code></pre>
  
  <p>How are values added on indexes? please help me understand this program.</p>