title: Count objects in array ignoring null
body: <p>I'm very junior, excuse me if it isn't an appropriate.</p>
  
  <p>Trying to count the objects in an array, ignoring null.
  This is my code so far:</p>
  
  <pre><code>    function countTheObjects (arr) {
  
          let count = 0;
  
            for (let i = 0; i &lt; arr.length; i++) {
               if (typeof arr[i] === 'object') {
                 count++;
               }
               if (arr[i] === null) {
                 count--;
               }
  
  
             }
           return count;
          }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Edit:</p>
  
  <p>All these codes you guys have given me return exactly the same error mine does. These are the tests the code has to pass:</p>
  
  <pre><code>describe('countTheObjects', function () {
    it('returns the count of objects inside an array of random data types', function () {
      expect(countTheObjects([])).to.equal(0);
      expect(countTheObjects([1, 3, 4, 5])).to.equal(0);
      expect(countTheObjects([1, 3, 4, 5, 'foo'])).to.equal(0);
      expect(countTheObjects([1, 3, 4, 5, {}, {}, {}, 'foo'])).to.equal(3);
      expect(countTheObjects([1, [], 3, 4, 5, {}, {}, {}, 'foo'])).to.equal(3);
      expect(countTheObjects([1, [], null, 3, 4, 5, {}, {}, {}, 'foo'])).to.equal(3);
      expect(countTheObjects([1, {}, [], null, null, 'foo', 3, 4, 5, {}, {}, {}, 'foo'])).to.equal(4);
    });
  });
  </code></pre>