Day 30

One month of the challenge is done...
I am working on learning JS constructors today...
#CodingPhase #TheCodingWay #365CodingPhaseChallenge

**********

// Constructor Pattern
function Fruit(name, color, shape) {
this.name = name;
this.color = color;
this.shape = shape;

this.describe = function() {
return 'A ' + this.name + ' is the color ' + this.color + ' and is the shape ' + this.shape;
}
}

var orange = new Fruit('orange', 'orange', 'round');
var melon = new Fruit('melon', 'green', 'round');

console.log(orange);
console.log(melon.shape);
console.log(melon.describe());
// You can also create arrays of objects
// End Object

Comments

Popular posts from this blog

Day 1

Day 365 + 1

Day 365 + 2