let employee = {
get workDuration() {
return this._workDuration;
},
set workDuration(value) {
if (value.length > 8) {
console.log("Work duration is too much, maximum 8 hours is allowed");
return;
}
this._workDuration = value;
}
};
employee.workDuration = 6;
console.log(employee.workDuration); // 6
employee.workDuration = 10; // Work duration is too much...