title: How to remove my nested ternary expressions in my code?
body: <p>I would like to clean up my code but I can't.  I would like to get rid of the nested ternary expressions. I work with react js 17.0.2. Do you have any ideas to help me?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  const buildNewFilters = (query, filtersIndex: Array&lt;string&gt;) =&gt; {
      const newFilters = {};
      for (let i = 0; i &lt; filtersIndex.length; i++) {
        newFilters[filtersIndex[i]] = router.query[filtersIndex[i]] ? typeof router.query[filtersIndex[i]] == ('string' || 'number') ? [router.query[filtersIndex[i]]] : router.query[filtersIndex[i]] : undefined
        if (filtersIndex[i] === 'designers' &amp;&amp; newFilters.designers) {
          newFilters.designers = newFilters.designers.map(designer =&gt; parseInt(designer));
        }
      }
      return newFilters;
    };</code></pre>
  </div>
  </div>
  </p>