Count how many times a conditional is true inside for loop with javascript

I have a for loop that runs over a range of cell values in a Google Apps script I'm trying to write, and each time it loops, it checks to see if a certain condition is true. If it's true, for the time being, it's logging the results to Logger.log().

I need the total number of results that show up in Logger.log() (in this case, it would be 10) and the best way I was able to think of doing that would be to count up by 1 each time that conditional is true in the for loop. It should be very simple to get a numerical value of how many results.

Here's the code I'm using:

var currentsheet = SpreadsheetApp.getActiveSheet();
var values = currentsheet.getRange("A28:E").getValues();

for (i=0; i<values.length; i++) {
if (values[i][3] === "Section 179 Depreciation") {
  var date = values[i][0];
  var amount = values[i][1];
  var desc = values[i][2];
  var expType = values[i][3];
  var notes = values[i][4];

 }
}

What am I missing?


Click here view more answers http://ift.tt/1NQ8jqT