code: function () {
              var results = [];
              var rollResult;
  
              // collect roll results
              for (var i = this.rolls; i; i--) {
                  results.push(random.int(this.sides));
              }
  
              if (this.specials.chooseLowest) { // choose lowest roll…
                  rollResult = Math.min.apply(Math, results);
              } else if (this.specials.chooseHighest) { // …or highest
                  rollResult = Math.max.apply(Math, results);
              } else { // or sum it up
                  rollResult = results.reduce(function(accum, roll) { // this effectively sums up all elements in array
                      return accum + roll;
                  }, 0);
  
                  if (this.specials.add) { // add constant if any
                      rollResult += this.specials.add;
                  }
              }
  
              return rollResult;
          }
docs: Perform rolls