Created
June 29, 2015 19:18
-
-
Save gs-ysingh/e5c368bd506676fdc13e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//index.js | |
var Project = function() { | |
this.info = {}; | |
this.setValues = function(info) { | |
for(var prop in info) { | |
if(this.info[prop] !== 'undefined') { | |
this.info[prop] = info[prop]; | |
} | |
} | |
}; | |
this.getInfo = function () { | |
return this.info; | |
}; | |
} | |
module.exports = function (info, type) { | |
//if(type == "Project") { | |
var instance = new Project(); | |
//} | |
//else if(type == "Other") {} | |
instance.setValues(info); | |
return instance; | |
} | |
//app.js | |
var Project = require('./Project'); | |
var webApp = Project({ | |
name: 'Twitter', | |
members: 3, | |
startDate: 2015 | |
}); | |
var mobileApp = Project({ | |
name: 'Facebook', | |
members: 5, | |
startDate: 2016 | |
}); | |
console.log(webApp.getInfo()); | |
console.log(mobileApp.getInfo()); | |
console.log(webApp.getInfo()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment