This piece of code is repeated a lot throughout my code, but x, y, and z change of course. Is there a better way?
if (x == "hour") {
y = z * 60;
} else if (x == "day") {
y = z * 1440;
} else if (x == "week") {
y = z * 10080;
}
Update..there is store.getters involved. They are not plain variables.
if (this.tempUsersTriggerIntervelIdentifier === "minute") {
this.convertedNewUsersTriggerIntervel =
this.$store.getters.getUsersTriggerTime;
} else if (this.tempDefaultRunIntervelIdentifier == "hour") {
this.convertedNewDefaultRunIntervel =
this.$store.getters.getOrganizationsDefaultTriggerTime * 60;
} else if (this.tempDefaultRunIntervelIdentifier == "day") {
this.convertedNewDefaultRunIntervel =
this.$store.getters.getOrganizationsDefaultTriggerTime * 1440;
} else if (this.tempDefaultRunIntervelIdentifier == "week") {
this.convertedNewDefaultRunIntervel =
this.$store.getters.getOrganizationsDefaultTriggerTime * 10080;
}
I want to do the best possible practice.
Aucun commentaire:
Enregistrer un commentaire