Closed
Description
In the constructor
change this._name = name;
into this.name = name;
or as it is the code will not do what it is intended to do.
The final code should be:
class User { constructor(value) { // invokes the setter this.name = value; } get name() { return this._name; } set name(value) { if (value.length < 4) { alert("Name too short."); return; } this._name = value; } }
Metadata
Metadata
Assignees
Labels
No labels