title: String incremental concatenation in a for-loop ignores "0" for some reason
body: <p>I'm writing a function to get a number string from a string`, which works like this:</p>
  
  <ul>
  <li>For each character in the string, checks if it's a digit from <code>0</code> to <code>9</code></li>
  <li>If it is, includes it in a new string</li>
  <li>Continues until the end of the string. If the string is <code>a0b109mmn5</code>, the function should return <code>01095</code>.</li>
  </ul>
  
  <pre><code>function stringToDigit(string) {
      if (string.length == 1) {
          switch (string) {
              case "0":
                  return 0;
              case "０":
                  return 0;
              case "1":
                  return 1;
              case "１":
                  return 1;
              case "2":
                  return 2;
              case "２":
                  return 2;
              case "3":
                  return 3;
              case "３":
                  return 3;
              case "4":
                  return 4;
              case "４":
                  return 4;
              case "5":
                  return 5;
              case "５":
                  return 5;
              case "6":
                  return 6;
              case "６":
                  return 6;
              case "7":
                  return 7;
              case "７":
                  return 7;
              case "8":
                  return 8;
              case "８":
                  return 8;
              case "9":
                  return 9;
              case "９":
                  return 9;
          }
      }
  }
  function stringToNum(string) {
      var numString = "";
      for (var i = 0; i &lt; string.length; i++) {
          if (stringToDigit(string[i])) numString += string[i];
      }
      return numString;
  }
  // $.writeln(stringToDigit("0"));
  // $.writeln(stringToNum("000"));
  console.log(stringToDigit("0")); // gets 0, good
  console.log(stringToDigit("00")); // gets undefined, good
  console.log(stringToDigit("a")); // gets undefined, good
  console.log(stringToNum("a000b1c2d3e4f5g6h7i8j9")); // gets 123456789, not 000123456789, NOT GOOD!
  </code></pre>
  
  <p>However, for some reason, I can't include "0" in the result. I've tried both Visual Studio Code (with an console add-on whose name I forgot) and Adobe ExtendScript Toolkit CC, so I wonder if this is just how JavaScript works.</p>