Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################################################
- ##################### OOJS Stamps ##################
- ################################################################
- var StampCollection = function(stamps){
- this.stamps = stamps
- }
- StampCollection.prototype.stampNamed = function (stampName) {
- return this.stamps.find(function(stamp){
- return stamp.name === stampName;
- })
- }
- StampCollection.prototype.stampsIssued = function (issueDate) {
- return this.stamps.filter(function(stamp){
- return stamp.issueDate === issueDate;
- })
- }
- StampCollection.prototype.value = function() {
- return sum = this.stamps.reduce(function(total,stamp){
- return total + stamp.maximumAppraisal()
- }, 0)
- }
- ###########################################################################
- #################### OOJS Stamp Collection ##################
- ###########################################################################
- var StampCollection = function(stamps){
- this.stamps = stamps
- }
- StampCollection.prototype.stampNamed = function (stampName) {
- return this.stamps.find(function(stamp){
- return stamp.name === stampName;
- })
- }
- StampCollection.prototype.stampsIssued = function (issueDate) {
- return this.stamps.filter(function(stamp){
- return stamp.issueDate === issueDate;
- })
- }
- StampCollection.prototype.value = function() {
- return sum = this.stamps.reduce(function(total,stamp){
- return total + stamp.maximumAppraisal()
- }, 0)
- }
- ###########################################################################
- #################### OOJS Stamp Collection ##################
- ###########################################################################
- var Stamp = function(params) {
- this.name = params.name;
- this.issueDate = params.issueDate;
- this.appraisalValues = params.appraisalValues;
- }
- Stamp.prototype.averageAppraisal = function() {
- var sum = this.appraisalValues.reduce(function(a,b){
- return a + b
- }, 0);
- return sum / this.appraisalValues.length;
- }
- Stamp.prototype.maximumAppraisal = function() {
- var max = 0;
- for(var i = 0; i < this.appraisalValues.length; i++){
- if( this.appraisalValues[i] > max){
- max = this.appraisalValues[i]
- }
- }
- return max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement