var animal = function(animal, noise) {
  var actions = {};
  actions.animal = animal;
  actions.makeNoise = function() {
    return noise;
  }
  return actions;
}

var pig = animal('pig', 'Oinkkk');
// Pig
console.log(pig.animal);

var dog = animal('dog', 'Wooofff');
// Wooofff
console.log(dog.makeNoise());

Codepen example

Worthy of Note

Worthy of Note is a site aimed at Web Designers & Developers. It offers a wide range of resources to help assist anyone in the web industry.

View