Skip to content

Instantly share code, notes, and snippets.

@karlwestin
Created January 30, 2012 23:15
Show Gist options
  • Save karlwestin/1707420 to your computer and use it in GitHub Desktop.
Save karlwestin/1707420 to your computer and use it in GitHub Desktop.
The bowling Kata, my version with array.shift();
var score = function() {
var score = 0;
for(var i = 0; i < 10; i++) {
if(rolls[0] === 10)
score += rolls.shift() + rolls[0] + rolls[1];
else if(rolls[0] + rolls[1] === 10)
score += rolls.shift() + rolls.shift() + rolls[0];
else
score += rolls.shift() + rolls.shift();
}
return score;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment