title: Snowflake UDF & Javascript - Issue with JavaScript compilation error: Uncaught SyntaxError
body: <p>Disclaimer:  I'm new to JavaScript &amp; new to writing JavaScript UDFs in Snowflake.</p>
  
  <p>I'm attempting to build a UDF which will "clean" the string of any characters where the ascii code is not between 32 &amp; 127.  When I attempt to use this function, I get the error:</p>
  
  <pre><code>Reason:
  SQL Error [100131] [P0000]: JavaScript compilation error: Uncaught SyntaxError: missing ) after
  argument list in CLEAN at '    FOR (i = 0; i &lt; value.length; i++) {' position 13
  </code></pre>
  
  <p>After searching around for what in the syntax could be causing this problem, I'm no further along. The value being input is a length 3 string, with the following ascii codes: 0, 13, 0</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION clean(value STRING)
      RETURNS string LANGUAGE JAVASCRIPT
      AS 
      $$ 
      var i = 0;
      var letter = "";
      var newValue = "";
      FOR (i = 0; i &lt; value.length; i++) {
          letter = value[i].charCodeAt(0)
          IF ( letter &gt;= 32 &amp;&amp; letter &lt;= 126) {
              newValue += value[i];
          } elseif (letter = 0) {
              newValue += value[i];
          }
      }
  RETURN newValue
  $$;
  </code></pre>