Do Class Methods Require Return Statements?

Hello,
I was wondering if it is best practice to have return statements at the end of class methods. For example, in the code below I am writing a method for the Nurse class which adds a new certification to the Nurse instance’s certification array. Do I need to add a return statement to the addCertification method or no? The code seems to work fine without a return statement.

addCertification(newCertification) {
    this._certifications.push(newCertification);
  }

or

addCertification(newCertification) {
    this._certifications.push(newCertification);
    return;
  }

The return statement is not mandatory if your function is returning nothing and is the function’s last statement.
And the best practice is to not write it in this case :slight_smile:

1 Like