title: In Javascript, the same input data is only different in length, but long data does not run correctly
body: <p>This is my code for this part.</p>
  <pre><code>function gcodeXY(source){
      var [xVal, yVal] = source.split(&quot;,&quot;);
      return `X${xVal} Y${yVal}`
  }
  let last=&quot;&quot;;
  let start=&quot;X0 Y0&quot;;//another side effect :-(
  function mapGroup(grp){
      let s=grp.split(&quot; &quot;);
      if (s[0]==&quot;M&quot;){
          start=gcodeXY(s[1]);
          last=s[1];
          return &quot;G0 F200 &quot;+start;
      }
      else if (s[0]==&quot;L&quot;){
          start=gcodeXY(s[1]);
          return &quot;G1 F100 &quot;+start;
      }
      else if (s[0]==&quot;z&quot;){
          start= gcodeXY(last);
          last=s[1];
          //start=&quot;X0 Y0&quot;;
          return &quot;G1 F100 &quot;+start;
      }
      return grp;
  }
  function processPathLettersIntoArray(source){
      const result = source.replace(/M/g, &quot;;M&quot;).replace(/L/g, &quot;;L&quot;).replace(/z/g, &quot;;z&quot;).split(';').slice(1);
      return result.map(mapGroup);
  }
  
  function path2gcode(source){
      source = processPathLettersIntoArray(source);
      return source;
  }
  </code></pre>
  <p>This is the output instruction code.</p>
  <pre><code>console.log(path2gcode(svg).join(&quot;\n&quot;));
  </code></pre>
  <p>When running short input, it can run completely.
  You can see the detail in the image.<a href="https://i.stack.imgur.com/ICO4p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ICO4p.png" alt="enter image description here" /></a></p>
  <p>But when I input long data, the code runs without any problems, but the ‘z’ is not recognized. The picture shows part of the input and output.
  <a href="https://i.stack.imgur.com/MSUqf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MSUqf.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/KziME.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KziME.png" alt="enter image description here" /></a></p>
  <p>So my problem is that I can't find what's wrong with my code that makes parts of the longer data unreadable.Then if you can, please tell me how to produce tab file. Thank you all！</p>