<commit_before>function BowlingGame() {
  this.rolls = [];
};

BowlingGame.prototype.roll = function(pinsDown) {
  this.rolls.push(pinsDown);
};

BowlingGame.prototype.score = function() {
  let score = 0;
  let i = 0;
  for (var frame = 0; frame < 10; frame++) {
    // line below: if the roll1(i) in the rolls list + the roll2(i+1) in the rolls list is equal to 10, then add 10 to the score + the amount of the roll3(i+2) in the rolls list. i+=2 ensures the new total includes the bonus and the third roll. 
      if(this.rolls[i] + this.rolls[i+1] === 10){
        score += 10 + this.rolls[i+2];
        i+=2;
      } else {
          score += this.rolls[i] + this.rolls[i+1];
          i+=2;
      }
  }
  return score;
};<commit_msg>Score method refactor extracts spare logic to new  method in test doc<commit_after>function BowlingGame() {
  this.rolls = [];
};

BowlingGame.prototype.roll = function(pinsDown) {
  this.rolls.push(pinsDown);
};

BowlingGame.prototype.score = function() {
  let score = 0;
  let i = 0;
  for (var frame = 0; frame < 10; frame++) {
    // line below: if the roll1(i) in the rolls list + the roll2(i+1) in the rolls list is equal to 10, then add 10 to the score + the amount of the roll3(i+2) in the rolls list. i+=2 ensures the new total includes the bonus and the third roll.
      if(this.isSpare(i)){
        score += 10 + this.rolls[i+2];
        i+=2;
      } else {
          score += this.rolls[i] + this.rolls[i+1];
          i+=2;
      }
  }
  return score;
};

BowlingGame.prototype.isSpare = function(i) {
  return this.rolls[i] + this.rolls[i+1] === 10;
};
{'fraction_non_alphanumeric': 0.1431238332296204, 'fraction_numerical': 0.029869321717486, 'mean_word_length': 2.801418439716312, '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': '7435176', 'n_tokens_mistral': 601, 'n_tokens_neox': 563, 'n_words': 177}