4. Methods


#1

https://www.codecademy.com/courses/learn-javascript-classes/lessons/classes/exercises/methods?action=lesson_resume&course_redirect=introduction-to-javascript

I’m having issues with the last step:

  takeVacationDays(daysOff) {
    this._remainingVacationDays -= this.daysOff;
  }

The whole code:

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 -= this.daysOff;
  }
}

const surgeonCurry = new Surgeon('Curry', 'Cardiovascular');
const surgeonDurant = new Surgeon('Durant', 'Orthopedics');


#2

Oh, never mind, I got it. My mistake was actually with the getter.


#3

Within takeVacationDays the parameter daysOff is bound to the this keyword, remove the keyword so that your input will be recognized by takeVacationDays


#4

Thanks, that was also one of my mistakes.