title: How to add a div every 3rd map/loop inside map react function
body: <p>I am trying to add a div every 3rd loop when mapping through my profile objects. This is so I can show 3 items at a time in the carousel setting of my little app. However I am getting syntax errors, can anybody help?!</p>
  
  <p><a href="https://i.stack.imgur.com/hV2M9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hV2M9.png" alt="enter image description here"></a></p>
  
  <pre><code>// Renders the selected profile
  let renderProfilesCarousel = selectedProfile.map(profile =&gt; {
  
    return(
  
      for (var i = 0; i &lt; selectedProfile.length; i++) {
        if (i % 3 === 2) {
          &lt;div className="sliderContainer"&gt;
        }
      }
  
      &lt;a href={profile.postUrl} target="_blank" data-interception="off" key={shortid.generate()}&gt; 
        &lt;div&gt; 
          &lt;DocumentCard
            aria-label={profile.postContent}
            className={styles.linkedInDocCard}
          &gt; 
            { profile.imgUrl &amp;&amp; 
              &lt;Image
                src={profile.imgUrl}
                imageFit={ImageFit.cover}
                height={168}
              /&gt;
            }
          &lt;/DocumentCard&gt;
        &lt;/div&gt;
      &lt;/a&gt;
  
      for (var i = 0; i &lt; selectedProfile.length; i++) {
        if (i % 3 === 2) {
          &lt;/div&gt;
        }
      }
  
    )
  });
  </code></pre>