Methods exercise

Hello, I am working on the Methods exercises
Here is my full code, which turns out true:

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) {
    return this._remainingVacationDays -= daysOff
  }
}

const surgeonRomero = new Surgeon('Francisco Romero', 'Cardiovascular');
const surgeonJackson = new Surgeon('Ruth Jackson', 'Orthopedics');

However in this part:

get remainingVacationDays() {
    return this._remainingVacationDays 
  }

If I changed the code to return this._remainingVacationDays = remainingVacationDays, it wouldn’t run. Can you tell me which error it is? Thank you!

why would want to do this?

you can’t assign and return in one go/operation/line

1 Like