I have a ton of if else statements, all changing the value of an object depending on their condition. I would like to know if there is another way to write this code so it can be condensed/simplified and doesn't take up do much space. I have the following code:
if (inputOne == "Yes") {
inputOne = "517"
}else{
inputOne = "518"
}
if (inputTwo == "Yes") {
inputTwo = "518"
}else{
inputTwo = "519"
}
if (inputThree == "Yes") {
inputThree = "519"
}else{
inputThree = "520"
}
if (inputFour == "Yes") {
inputFour = "520"
}else{
inputFour = "521"
}
And so on... I will be changing the value of multiple objects based on their inputs. Are there any other ways to write this in JavaScript that could save time or make it look cleaner?
Aucun commentaire:
Enregistrer un commentaire