Check Three Dom Elements to See if they are empty or not and return detailed result I am checking three elements on the DOM to see if they are empty or not so that I can run only the Ajax calls that I should run and save on overall bandwidth. The code works but it &quot;smells bad&quot;. Here is my source.
const processValues = (area, city, text) =&gt; {
    if (area.val() &amp;&amp; city.val() &amp;&amp; text.val()) {
        return 'all';
    } else if (area.val() &amp;&amp; city.val() &amp;&amp; !text.val()) {
        return 'areaCity';
    } else if (area.val() &amp;&amp; !city.val() &amp;&amp; text.val()) {
        return 'areaText';
    } else if (area.val() &amp;&amp; !city.val() &amp;&amp; !text.val()) {
        return 'city';
    } else if (!area.val() &amp;&amp; city.val() &amp;&amp; text.val()) {
        return 'cityText';
    } else if (!area.val() &amp;&amp; !city.val() &amp;&amp; text.val()) {
        return 'text';
    } else if (!area.val() &amp;&amp; city.val() &amp;&amp; !text.val()) {
        return 'city';
    } else {
        return 'none';
    }
};

I will be repeating this check in a few methods and I will be using a switch statement in those methods with the returned string values. If there is a better way to do this, I would appreciate it.
After speaking with some friends, this is seen as the best solution. One adjustment to the return values was required however; change the casing from camel case to title case. I am also using constants to make sure that return values can be consistently used properly.
/**
 * Check the three dom elements to see if they are empty or not and return detailed result.
 * @param {jQuery|HTMLElement} area Area input field.
 * @param {jQuery|HTMLElement} city City input field.
 * @param {jQuery|HTMLElement} text Text input field.
 * @return {string} Detailed result of which input fields are empty.
 * If all are filled, returns &quot;all&quot;.
 * If none are filled, returns empty string.
 */
export const processValues = (area, city, text) =&gt; {
    const a = (area.val()) ? 'Area' : '';
    const c = (city.val()) ? 'City' : '';
    const t = (text.val()) ? 'Text' : '';
    if (a !== &quot;&quot; &amp;&amp; c !== &quot;&quot; &amp;&amp; t !== &quot;&quot;) {
        return &quot;all&quot;;
    } else {
        return a + c + t;
    }
};

export const ALL = &quot;all&quot;;
export const AREA_CITY = &quot;AreaCity&quot;;
export const AREA_TEXT = &quot;AreaText&quot;;
export const AREA = &quot;Area&quot;;
export const CITY_TEXT = &quot;CityText&quot;;
export const CITY = &quot;City&quot;;
export const TEXT = &quot;Text&quot;;
```