peopleFactory

Factory

by jonex9x9

JavaScript

var peopleFactory = function(name, age, state){

var temp = {};

temp.age = age;
temp.name = name;
temp.state = state;

temp.printPerson = function(){
    console.log(this.name + ", " + this.age + ", " + this.state);
    
};

return temp;

};

var person1 = peopleFactory('Jon', 35, 'MI');
var person2 = peopleFactory('Rhunell', 38, 'MI');

person1.printPerson('Jon', 35, 'MI');
person2.printPerson('Rhunell', 38, 'MI');