Javascript prototypes
I’m really beginning to groove dynamic languages these days.
DailyCalorieNeed.prototype.getKgPerWeek = function() {
return (((this.tee.value - this.value) * 7) / 7800).round();
}
Number.prototype.round = function() {
return Math.round(this * 100) / 100;
}
Now I’m sure there are libraries out there that will give me better rounding, that’s not the point. The point is that you can just change anything you like to extend your environment so it is more expressive.
The prototype library provides an instance method version of Math.round() too.