Permalink
Browse files

No need to convert Numbers into Numbers

  • Loading branch information...
1 parent 5c52586 commit 268260e24857c45953566cfcf92e907798cf86dd @josmas josmas committed with May 1, 2011
Showing with 8 additions and 8 deletions.
  1. +8 −8 josmas/spec/BowlingSpec.js
@@ -72,30 +72,30 @@ var Game = function() {
for (var frame = 0; frame < 10; frame+=1) {
if ( isStrike(i) ) {
totalScore += 10;
- if (Number(rolls[i+1]))
- totalScore += Number(rolls[i+1]);
- if (Number(rolls[i+2]))
- totalScore += Number(rolls[i+2]);
+ if (rolls[i+1])
+ totalScore += rolls[i+1];
+ if (rolls[i+2])
+ totalScore += rolls[i+2];
i += 1;
}
else if ( isSpare(i) ) {
- totalScore += (10 + Number(rolls[i+2]));
+ totalScore += (10 + rolls[i+2]);
i += 2;
}
else {
- totalScore += (Number(rolls[i]) + Number(rolls[i+1]));
+ totalScore += (rolls[i] + rolls[i+1]);
i += 2;
}
};
return totalScore;
};
var isSpare = function(index) {
- return (Number(rolls[index]) + Number(rolls[index+1]) === 10);
+ return ((rolls[index] + rolls[index+1]) === 10);
};
var isStrike = function(index) {
- return (Number(rolls[index]) === 10);
+ return (rolls[index] === 10);
};
return {
roll: roll,

0 comments on commit 268260e

Please sign in to comment.