title: Split a long array element into two elements while respecting words
body: <p>I have an array that contains dialogue strings of varying length.</p>
  <p>I need to split elements that have more than 200 characters into two separate elements. I would need to do the split so that no words are cut in half (but instead split based on whitespace).</p>
  <p>Edit:
  This question is different from simply splitting a string based on white space because it involves inserting and removing elements in the array in the right locations.</p>
  <p>Example:</p>
  <pre><code>[
  
  &quot;Hello there I'm shorter than 200 characters so do nothing with me&quot;,
  
  &quot;I'm longer than 200 characters though so I should be split into two consecutive elements so that my first half stays where I am currently located in the array and my second half goes to the very next position in the array.&quot;,
  
  &quot;I'm shorter than 200 so I just stay here as the last element.&quot;
  
  ]
  </code></pre>
  <p>Desired result:</p>
  <pre><code>
  [
  
  &quot;Hello there I'm shorter than 200 characters so do nothing with me&quot;,
  
  &quot;I'm longer than 200 characters though so I should be split into two consecutive elements so that my first&quot;,
  
  &quot;half stays where I am currently located in the array and my second half goes to the very next position in the array.&quot;,
  
  &quot;I'm shorter than 200 so I just stay here as the last element.&quot;
  
  ]
  
  </code></pre>
  <p>Failed attempt (I have no idea really):</p>
  <pre><code>
  const myArray = [
  
  &quot;Hello there I'm shorter than 200 characters so do nothing with me&quot;,
  
  &quot;I'm longer than 200 characters though so I should be split into two consecutive elements so that my first half stays where I am currently located in the array and my second half goes to the very next position in the array.&quot;,
  
  &quot;I'm shorter than 200 so I just stay here as the last element.&quot;
  
  ]
  
  myArray.forEach((element) =&gt; {
    if (element.length &gt; 200){
  
  let split = element.substring(0,element.length/2);
  myArray.push(split);
  
  }
  });
  
  
  </code></pre>