<commit_before>

function BowlingGame () {
  this.score = [];
  this.roundScore = [];
  this.round = 0;
  this.pins = 10;
  this.finalScore = 0

};

BowlingGame.prototype.firstBowl = function(bowl) {
  if (bowl === 10) {
    this.roundScore.push(bowl);
    this._runRound();
  } else {
  this.pins -= bowl;
  this.roundScore.push(bowl);
  }
};

BowlingGame.prototype.secondBowl = function(bowl) {
  this.roundScore.push(bowl);
  this._runRound();
};

BowlingGame.prototype._bowlCalculator = function() {
   return Math.floor(Math.random() * this.pins) + 0;
};

BowlingGame.prototype._runRound = function() {
  this.score.push(this.roundScore);
  this.pins = 10;
  this.round++;
  this.finalScore = this._getScore();


};







BowlingGame.prototype._getScore = function() {
  var score = [].concat.apply([], this.score);
  var scoreindex = 0;
  var self = this;
  var finalScore = 0;

  function isStrike() {
  return score[scoreindex] === 10;
  };

  function strikeBonus() {
  return score[scoreindex + 1] + score[scoreindex + 2];
  };

  function isSpare(){
    return score[scoreindex] + score[scoreindex]

  }

   function SumOfRound() {
    return score[scoreindex] + score[scoreindex + 1];
  };


  for (var turn = 0; turn < (self.round); turn++){

    if (isStrike()) {
      finalScore += 10 + strikeBonus();
      scoreindex++;
    } else {
      finalScore += SumOfRound();
      scoreindex += 2;
    }

  }
console.log(finalScore);
return finalScore;


};

<commit_msg>added spare functionality<commit_after>

function BowlingGame () {
  this.score = [];
  this.roundScore = [];
  this.round = 0;
  this.pins = 10;
  this.finalScore = 0

};

BowlingGame.prototype.firstBowl = function(bowl) {
  if (bowl === 10) {
    this.roundScore.push(bowl);
    this._runRound();
  } else {
  this.pins -= bowl;
  this.roundScore.push(bowl);
  }
};

BowlingGame.prototype.secondBowl = function(bowl) {
  this.roundScore.push(bowl);
  this._runRound();
};

BowlingGame.prototype._bowlCalculator = function() {
   return Math.floor(Math.random() * this.pins) + 0;
};

BowlingGame.prototype._runRound = function() {
  this.score.push(this.roundScore);
  this.pins = 10;
  this.round++;
  this.finalScore = this._getScore();


};







BowlingGame.prototype._getScore = function() {
  var score = [].concat.apply([], this.score);
  var scoreindex = 0;
  var self = this;
  var finalScore = 0;

  function isStrike() {
  return score[scoreindex] === 10;
  };

  function strikeBonus() {
  return score[scoreindex + 1] + score[scoreindex + 2];
  };

  function isSpare(){
    return score[scoreindex] + score[scoreindex + 1] === 10;
  };

  function spareBonus(){
    return score[scoreindex + 2];
  };

   function SumOfRound() {
    return score[scoreindex] + score[scoreindex + 1];
  };


  for (var turn = 0; turn < (self.round); turn++){

    if (isStrike()) {
      finalScore += 10 + strikeBonus();
      scoreindex++;
    } else if (isSpare()) {
      finalScore += 10 + spareBonus();
      scoreindex += 2;
    } else {
      finalScore += SumOfRound();
      scoreindex += 2;
    }

  }
console.log(finalScore);
return finalScore;


};


{'fraction_non_alphanumeric': 0.1603563474387528, 'fraction_numerical': 0.014953865733375756, 'mean_word_length': 3.1864181091877497, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4175805', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1075, 'n_words': 215}