code: function splitIntoBatches(arrayToSplit, batchSize) {
    var arrayBatches = [];
    var minSlice = 0;
    var finish = false;
    for (var maxSlice = batchSize; maxSlice < Infinity; maxSlice += batchSize) {
      if (maxSlice >= arrayToSplit.length) {
        maxSlice = arrayToSplit.length;
        finish = true;
      }
      arrayBatches.push(arrayToSplit.slice(minSlice, maxSlice));
      minSlice = maxSlice;
      if (finish) {
        break;
      }
    }
    return arrayBatches;
  }
docs: Breaks an array into pieces, putting them in another array.
  
  @param {Array} arrayToSplit array to split
  @param {number} batchSize maximum number of items in each array at end
  @return array containing other arrays, which contain a maxiumum number of items in each.