class Surgeon {
constructor(name, department) {
this._name = name;
this._department = department;
this._remainingVacationDays = 20;}
get name(){
return this._name;
}get department(){
return this._department;
}get remainingVacationDays(){
return this._remainingVacationDays;
}takeVacationDays(daysOff){
// this._remainingVacationDays - daysOff = this._remainingVacationDays;this._remainingVacationDays = this._remainingVacationDays - daysOff;
}
}const surgeonCurry = new Surgeon(‘Curry’, ‘Cardiovascular’);
const surgeonDurant = new Surgeon(‘Durant’, ‘Orthopedics’);
My instructions:
Under the remainingVacationDays getter, create a method called takeVacationDays that accepts one argument named daysOff.
Inside of the method, subtract daysOff from the number saved to _remainingVacationDays. Set _remainingVacationDays to the result.
I’m interested in:
takeVacationDays(daysOff){
// this._remainingVacationDays - daysOff = this._remainingVacationDays;this._remainingVacationDays = this._remainingVacationDays - daysOff;
}
}
The commented line is what I had.
The non-commented line is what I found here in the forums.
I understand that it wants me to take subtract the daysOff from the this._remainingVacationDays and then set this equal to the new this._remainingVacationDays.
Why is that my line of code didn’t work?
Thanks!