Situation
When the input is identified as a "start", the program will automatically calculate the corresponding "end" value and update the page with it. If the input is an "end", simply display this value on the page without any modifications.
I am in the process of creating a custom class to manage this task efficiently.
class EndVal(start_value) {
constructor() {
this.end_value = start_value + 10
$("#end").text(this.end_value)
}
static prefill(end_value) {
$("#end").text(end_value)
}
}
The code provided above allows you to handle "start" inputs by utilizing new EndVal(start_value)
, while for "end" values, you can directly use EndVal.prefill(end_value)
. However, I find this approach slightly repetitive. Is there a way to streamline it and establish a connection between instance and class methods?