Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More code cleanup with underscore and logic.

  • Loading branch information...
commit 0101a0ae6611849da5507038c8661df2bb203418 1 parent 4b6e96e
@Glench authored
Showing with 4 additions and 12 deletions.
  1. +4 −12 ultimatum.js
View
16 ultimatum.js
@@ -259,23 +259,15 @@ var Ultimatum = function(numPlayers, totalAmount, percentNeeded, currentPlayerId
ultimatum.validate = function() {
// have to validate they didn't put an amount over the total that they
// were allowed to put
- if (ultimatum.calculatedTotal() != ultimatum.totalAmount) {
- return false;
- }
- return true;
+ return ultimatum.calculatedTotal() == ultimatum.totalAmount;
};
ultimatum.validatePlayers = function() {
// have to validate they didn't put an amount over the total that they
// were allowed to put
- var player;
- for (var i=0; i < this.players.length; ++i) {
- player = this.players[i];
- if (!player.validate()) {
- return false;
- }
- }
- return true;
+ return _.all(this.players, function(player) {
+ return player.validate();
+ });
};
ultimatum.allOffersProcessed = function() {
Please sign in to comment.
Something went wrong with that request. Please try again.