title: Placing an element in the same index as element in an array
body: <p>I'm trying to figure out the best way to take an element, compare it to elements in an existing array and if that returns true, push that element into another array with the same index.</p>
  <p>I currently have an array but it needs to appear in a certain order so what I've done is created an array with the order it needs to be in. I thought about creating an object where each value of the key is an array and push the elements into the array with is equal to the key but not sure if that's the best way to go about it.</p>
  <p>This is the code I am currently working with :</p>
  <pre><code>let categories = [];
    const categoryOrder = [
      &quot;Headings&quot;,
      &quot;Text&quot;,
      &quot;Lists &amp; Menus&quot;,
      &quot;Quotes&quot;,
      &quot;Banners&quot;,
      &quot;Images&quot;,
      &quot;Videos&quot;,
      &quot;Galleries&quot;,
      &quot;Logos&quot;,
      &quot;Clickthrough Images&quot;,
      &quot;Buttons &amp; CTAs&quot;,
      &quot;Lines &amp; Dividers&quot;,
      &quot;Actions&quot;,
      &quot;Social Media &amp; Integrations&quot;,
      &quot;Blog, Events &amp; Podcast&quot;,
      &quot;Ecommerce&quot;,
      &quot;Navigation&quot;,
      &quot;Footers&quot;,
      &quot;Premium&quot;,
      &quot;Misc&quot;,
    ];
  
    defaultComponents &amp;&amp;
      defaultComponents.forEach((component) =&gt; {
        categories.push(component.category);
      });
    categories = [...new Set(categories)];
  </code></pre>
  <p>Hope this makes sense.</p>