Ball Constructor

Trying to figure out how to use constructors in JavaScript

by Zecheng Hu

JavaScript

function Ball( type, grip, shape ) {
  this.type = type;
  this.grip = grip;
  this.shape = shape;
  this.caught = function( who,how ) {
    this.who = who;
    this.how = how;
  };
  Ball.prototype.player = function() {
    console.log (this.who + "caught the ball" + this.how + "that was a" + this.type + "shaped like a " + this.shape + "thrown with a" + this.grip);
    };
};

var baseball = new Ball("Mickey Mantle","sliding","baseball","circle","fastball");

console.log(baseball);