JavaScript Class undefined



I was following instructions on Class part of JavaScript and couldn’t find what causes ‘undefined’ when I use this method


It’s checked as right answer… is it?

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


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



Hello -

I’m just learning this as well. The only thing that looks like might be missing is a return in your takeVacationDays() method.

I think it should look like this:

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

You might be able to just add the return to the beginning of the first line…

Hope this helps a little. Good Luck.


No return needed. The method is a setter acting upon an instance attribute.

You are logging the method’s return value (undefined). Instead of logging that, just invoke the method, then log the remaining days off.