mardi 22 juin 2021

simplify JS conditions into if else

I am trying to simplify this conditions into just if((A && B && C) || (!A && !B && !C)){..} else {..}.

if ((A && B && C) || (!A && !B && !C)) {
        delete options.state;
      } else if (A && B) {
        this.set(`controller.options.state`, 'A,B');
      } else if (A && C) {
        this.set(`controller.options.state`, 'A,C');
      } else if (B && C) {
        this.set(`controller.options.state`, 'B,C');
      } else if (A) {
        this.set(`controller.options.state`, 'A');
      } else if (B) {
        this.set(`controller.options.state`, 'B');
      } else if (C) {
        this.set(`controller.options.state`, 'C');
      }

Could you help me with this?

Aucun commentaire:

Enregistrer un commentaire