title: Find the number of subarrays in an array, which has the given sum
body: <p>Find the number of subarrays in an array, which has the given sum - here is my attempt but doesn't work properly</p>
  
  <pre><code>function getSubArrayCount(arr, sum) {
  
  for (var i = 0; i &lt; arr.length; i++) {
          var str = [];
          var csum= 0;
          var output = 0;
  
  for (var j = i; j &lt; arr.length; j++) {        
          csum+= arr[j];
          str.push(arr[j]);
          if (csum== sum) {       
                return(str[i]);     
               }
           }
       }
  }
  
  console.log(getSubArrayCount([1,2,3,2,1,8,-3],5))
  </code></pre>