mercredi 25 avril 2018

Checking Against Multiplw Variable

Not sure if there is a better solution, but it's kind of a general coding one; although currently, I am using JavaScript/jQuery.

I have four string variables being passed and need to look at all combinations of empty string or not.

For example:

var a;
var b;
var c;
var d;

function GetInfo(){
    if(a != '' && b == '' && c == '' && d == ''){ //DO SOMETHING }
    else if(a != '' && b != '' && c == '' && d == ''){ //DO SOMETHING }...
    else(a != '' && b != '' && c != '' && d == ''){//DO SOMETHING };
};

Currently, I have 16 lines/possibilities. Is their an easier, more concise way of doing this?

Aucun commentaire:

Enregistrer un commentaire