Check if the sum of all numbers in an array matches a given number, or 100 if no number was provided.
Array.prototype.checkSumOfValues = function() {
var a = arguments,
b = !!a[0],
sum = b ? a[0] : 100;
if (Math.round(eval(this.join('+'))) != sum) {
Debugger.log("The sum of the different pieces does not match " + sum + ".");
return false;
} else {
return true;
}
};