Run function on every 10th packet recieved in loop
<p>Below is a function that runs a drawAccel() function on every packet received from the server. darwAccel() builds out a strip chart so constantly running it on every every packet received is slow enough in IE8 that it causes things to break. I would like to run it on every 10th (or variable number) packet received. What would be a good approach for this?   </p>

<pre><code>function messagecb(header, message) {
    if(header.type == 6) {
      // processEchoReply(message);

    } else if(header.type == 4) {
        var accels = message.b64UnpackAccelMsg();

    for(var index = 0; index &lt; accels.length; ++index) {
        var accel = accels[index];
        var totalClock = accelEpochAdjust(accel.clock);

        addAccelDatum(totalClock, accel.x,  accel.y, accel.z);
    }

    drawAccel();

  } else if(header.type == 3) {
      // info
      var info2 = message.b64UnpackInfo2Msg();

      displayCurrentPosition(info2.fixtime, info2.lat, info2.lon, info2.alt);
      displayMobileStatus(info2.rssi, info2.bandClass, info2.batt);
  } else if(header.type == 11) {
      btReceive(header, message);
  }
}
</code></pre>

<p>Thanks!</p>
