title: TypeError: Cannot read property 'length' of null, how can i solve it?
body: <p>I'm still studying javascript and to practice I'm doing a series of exercises from codewars.com, and I'm having trouble with one of them.
  The request is as follows:
  Given an array of integers.</p>
  <p>Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.</p>
  <p>If the input array is empty or null, return an empty array.</p>
  <p>For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should return [10, -65].</p>
  <p>I made the following algorithm which works in all cases:</p>
  <pre><code>function countPositivesSumNegatives(input) {
    var arrOutput = []; //declare the final array
    var pos = 0; //declare the positive 
    var neg = 0; //declare the negative
    var check, ss;
  
    for (var x = 0; x &lt; input.length; x++){
      if(input[x]&gt;0){ pos++; }
      else{ neg = neg + input[x] ; }
      arrOutput = [pos, neg]
    }
    
    return arrOutput;
  }
  </code></pre>
  <p>but it returns me the following error:</p>
  <pre><code>TypeError: Cannot read property 'length' of null
      at countPositivesSumNegatives (test.js:8:29)
      at Context.&lt;anonymous&gt; (test.js:39:18)
      at processImmediate (internal/timers.js:461:21)
  </code></pre>
  <p>and because of this error i can't pass the test.
  How can i solve it, and why it gives me this error?</p>