title: Javascript callback function with boolean values
body: <pre><code>var each = function(collection, callback){
      if(Array.isArray(collection)){
          for(var i=0;i&lt;collection.length;i++){
              callback(collection[i]);
          }
      }else{
          for(var key in collection){
              callback(collection[key]);
          }
      }
  };
  
  
  var filter = function(collection, callback){
      each(collection, function(item){
          if(callback(item)){
              return item;
          }
     });
  };
  </code></pre>
  
  <p>How to write a callback function that would output each boolean value of the callback?</p>
  
  <p>// example, even of an array, [1,2,3,4,5] -> false, true, false, true, false</p>