|
function adminFactory(name, score) { |
|
const admin = new userFactory(name, score); |
|
admin.type = 'Admin'; |
|
return admin; |
|
} |
|
|
|
/* Put code here for a method called sharePublicMessage*/ |
|
userFunctionStore.sharePublicMessage = () => console.log('Welcome users!'); |
Above issue is with respect to Extension Question for - http://csbin.io/oop
The code does not prevent userFactory to access sharePublicMessage method.. Instead the solution should be to use Object.create in adminFactory function:
function adminFactory(name, score) {
// Put code here
let newAdminObj = userFactory(name,score);
newAdminObj = Object.create(adminFunctionStore);
newAdminObj.type = "Admin";
return newAdminObj;
}
// Put code here for a method called sharePublicMessage
adminFunctionStore.sharePublicMessage = () => console.log("Welcome users!")
cs-bin-solutions/oop.js
Lines 181 to 188 in 20de7d4
Above issue is with respect to Extension Question for - http://csbin.io/oop
The code does not prevent userFactory to access sharePublicMessage method.. Instead the solution should be to use Object.create in adminFactory function: