Created
January 30, 2012 23:15
-
-
Save karlwestin/1707420 to your computer and use it in GitHub Desktop.
The bowling Kata, my version with array.shift();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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