mercredi 6 septembre 2017

JavaScript - Get Value of First Condition Met

Wasn't quite sure how to title the question. Nonetheless - consider you have the following statement

if (messageOne || messageTwo || messageThree || messageFour) {
  // do something here ...
 }

How would you go about grabbing and using the message that gets met? For example

if (messageOne || messageTwo || messageThree || messageFour) {
  console.log(messageOne) // <-- but rather than hardcoding messageOne I want to be able to grab whichever one is executed
 }

Apologies if the question is poorly worded, can clarify if necessary.

Thanks!

Aucun commentaire:

Enregistrer un commentaire