title: Best way of splitting a string and create the following array: '1-2-3' -> ['1', '1-2', '1-2-3']
body: <p>the string is something like this:</p>
  <pre><code>const string = '1-2-3-4-5-6-7-...-n';
  </code></pre>
  <p>and I need an array like this:</p>
  <pre><code>const arr = ['1', '1-2', '1-2-3', '1-2-3-4', '1-2-...-n'];
  </code></pre>
  <p>I have go into this so far:</p>
  <pre><code>const str = '1-2-3'; 
  const arr = []; let actualValue = '';
  const splitArray = str.split('-');
  for (let i = 0; i &lt; splitArray.length; i++) {
    if (actualValue)         
      actualValue = actualValue + '-' + splitArray[i];     
    else 
      actualValue = splitArray[i];
    
    arr.push(actualValue); 
  }
  </code></pre>