I am faced with a scenario where I have two objects and I need to add new properties to them. The challenge is that I want to be able to choose which object to work with first before adding the new properties. Here's the proposed logic :
let customizeObjects = (function() {
// Define the Two Objects
let university = {}
let Person = {}
let addNewPropTo = (objName, newProp) => {
return objName[newProp] = null; // Issue in logic 1
}
let getProperties = (objName) => {
return Object.getOwnPropertyNames(objName)
}
return {
addNewPropTo,
getProperties
}
})();
customizeObjects.addNewPropTo('Person', 'Age'); // Issue in logic 2
customizeObjects.getProperties(Person) // Expected Output : Person = { Age : null }