I am getting this error…
why??
/home/ccuser/workspace/learn-javascript-classes-classes-inheritance-v/main.js:32
this._certifications.push(newCertification);
^
TypeError: Cannot read property ‘push’ of undefined
at Object. (/home/ccuser/workspace/learn-javascript-classes-classes-inheritance-v/main.js:32:21)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3
the code is …
class HospitalEmployee {
constructor(name) {
this._name = name;
this._remainingVacationDays = 20;
}
get name() {
return this._name;
}
get remainingVacationDays() {
return this._remainingVacationDays;
}
takeVacationDays(daysOff) {
this._remainingVacationDays -= daysOff;
}
}
class Nurse extends HospitalEmployee {
constructor(name, certifications) {
super(name);
this._certifications = certifications;
}
get certifications() {
return this._certifications
}
}
this._certifications.push(newCertification);
const nurseOlynyk = new Nurse(‘Olynyk’, [‘Trauma’,‘Pediatrics’]);
nurseOlynyk.takeVacationDays(5);
console.log(nurseOlynyk.remainingVacationDays);