mercredi 14 août 2019

Is there a short way of using the JS or operator if object properties in both conditions are the same? [duplicate]

i want to know if there is a shorter way of writing or || statements like this

if (driver.name === 'test' || driver.name === 'test2'){
  //do some stuff
}

Rather than repeating driver.name twice is there i way i can use it once and check for 2 different values for this object property

Aucun commentaire:

Enregistrer un commentaire