I made a mistake with the age property on these objects and when I try to reassign different values later, it won't change it at all.
I want this to work with the Object.create Method. What should I do to fix this?
var personProto = {
calculateAge: function() {
console.log(2019 - this.yearOfBirth)
},
fullName: function() {
console.log(this.name + ' ' + this.lastName)
}
}
var sam = Object.create(personProto, {
name: { value: "samuel" },
yearOfBirth: { value: 1092 },
lastName: { value: "max" },
job: { value: "developer" }
});
sam.yearOfBirth = 1992;
sam.calculateAge(); // 927
console.log(sam.calculateAge()); is giving me 927 assuming yearsOfBirth is still 1092 even if I changed it to 1992 and the output was supposed to be 27.
writable: false.