title: Function using reduce not working; returning false when should be true
body: <pre><code>var atLeast = function (tab,n,k){
      var frequencyK = tab.reduce(function (acc, val, array){
          if (val == k){
              return acc+1;
          }
      });
      return frequencyK &gt;= n;
  };
  console.log(atLeast([1,2,3,2,2,4,2,2],4,2));
  </code></pre>
  
  <p>This function is meant to return true if the argument <em>k</em> is repeated in the array <em>tab</em> at least <em>n</em> times. To do this I used reduce, and incremented the accumulator by 1 each time that the current value was equal to <em>k</em>. I then I compared the frequency of <em>k</em> calculated with the reduce function with <em>n</em>. </p>
  
  <p>The problem is that frequencyK ends up being NaN. I can't figure out why that is.</p>