Tengo una clase de presupuesto con una propiedad anual, mensual y semanal. ¿Hay una mejor manera de hacerlo que a continuación?:
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); } }