vendredi 26 avril 2019

More elegant ways of converting YES/NO to true/false

There might be a very basic thing that might be missing. Please let me know if there is a better way to do this which is much more elegant than using the ternary operator in javascript.

if (data.isYellowCupcake === YES) {
  dataCopy.isCupcake = true;
} else if (data.isYellowCupcake === NO) {
  dataCopy.isCupcake = false;
}

Aucun commentaire:

Enregistrer un commentaire