class Counter {
#count = 0;
get value() {
return this.#count;
}
set value(v) {
if (v < this.#count) throw new RangeError('Cannot decrease');
this.#count = v;
}
}
const c = new Counter();
c.value = 5;
let msg;
try {
c.value = 3;
} catch (e) {
msg = e.message;
}
c.value = 10;
console.log(msg, c.value); Post #3567
144
CHALLENGE