I have a Budget class with an annual, monthly, and weekly property. Is there a better way to do it than below?:
class Budget{
//based on choice, the initializer assigns, then calculates the two other properties
constructor(value, choice) {
this.value = value;
this.choice = choice;
this.annual = 0;
this.monthly = 0;
this.biweekly = 0;
}
initialize() {
this.choice == 1 ? (this.annual = this.value,
this.monthly = this.annual/12,
this.biweekly = this.annual/52) :
this.choice == 2 ? (this.monthly = this.value,
this.annual = this.monthly*12,
this.biweekly = this.annual/52):
(this.biweekly = this.value,
this.annual = this.biweekly*52,
this.monthly = this.annual/12);
}
}