Potential bug with Inheritance II

class HospitalEmployee{
  constructor (name)

Above is the beginning part of Inheritance II, which is found HERE!

I am able to make one this statement but not a second one. Is this a bug? I’m just making sure I’m not trying to do something that is broken (thus trying in vain).


look at the example in the exercise:

class Animal {
  constructor(name) {
    this._name = name;
    this._behavior = 0;

the constructor clearly uses curly brackets ({}), JS allows a shorthand by not using curly brackets, but then you can only have a single line within your constructor, given you have two lines, you can’t use this shorthand

class HospitalEmployee
  constructor (name) {
  this.name = name;

I have now continued on to the next part(step 2) and I cant shake off the feeling that there is a bug. I’m literally following the exact instructions.

Im continuing to meddle around with it for now.

nevermind I fixed it.


last time you thought there was a bug, the bug was in your code

I would put money on the fact that there is a bug in your code. (i already spotted it)

Seems you found it.

the low bar/underscore indicates we want to use getters and setters for this property


In the previous lesson, I noted that the underscore prevents some things? In your experience does underscored properties have more protection from other stuff?


some things, that is a bit vague.

The Javascript language does not give any special meaning to identifiers starting with underscore characters.

That said, it’s quite a useful convention for a language that doesn’t support encapsulation out of the box. Although there is no way to prevent someone from abusing your classes’ implementations, at least it does clarify your intent, and documents such behavior as being wrong in the first place.