Edit in JSRun

// function factory(type){
//   switch(type){
//     case 'D':
//       return new Date();
//     case 'O':
//       return {};
//     default:
//       return null
//   }
// }

// console.log(factory('D'))
// console.log(factory('O'))
function A(){}
function I(){}
function Factory(){}
Factory.prototype.create = function(type){
  switch(type) {
     case 'A':
      return new A;
    case 'I':
			return new I;
  }
}

var factory = new Factory()
console.log(factory.create('A'))
console.log(factory.create('I'))