How to gain access to if statement checked value ? in side the if block?

How to gain access to if statement checked value (case), inside the if block after the check happend ? instead of having to write another 4 conditional according to each case ?

if ((obj.a === '' || obj.b === '' || obj.c === '' || obj.d === '')) {
      console.log(what case has been triggered ?)
      selected.a ? something : null
      selected.b ? something : null
      selected.c ? something : null
      selected.d ? something : null
    }

Answer

You can create an object that contains the result of each of a comparisons in a object with the corresponding keys using Array.reduce:

const obj = { a: " ", b: " ", c: " ", d: " " };

const boolObj = Object.keys(obj).reduce((accum, key) => {
    accum[key] = obj[key] === " ";
    return accum;
}, {}); // result: {a: true, b: true, c: true, d: true}

Then, you can check for validity using Array.every:

if (Object.values(boolObj).every(val => val)) {
    // do something
}

However, since you did not provide some better context, I cannot give a better answer that fits your needs. To me, I think this is over-engineering, and I’m quite sure there probably are much better ways of solving the problem relative to your context.