title: find the length of a string in google script
body: <p>I'm trying to make a script for google sheet, who can count a letter in a text. But it seems that .length doesn't work. Anyone who can give directions on where to find the the solution. </p>
  
  <pre><code>    function Tjekkode(tekst , bogstav){
      var test = "";
      // find the length of laengdeTekst
      var laengdeTekst = tekst.length;
      var t = 0;
      // through the text character by character
      for ( var i = 1; i&lt;laengdeTekst ; i++) {
  
       var test = tekst.substr(i,1);
       if (test == bogstav) {
        // if the letter is found, it is counted up
        // REMEMBER == means compare
        var t = t + 1;
       }
      }
      // returns percent appearance of the letter
      Return = t / længdeTekst * 100
      }
  </code></pre>
  
  <p>Thanks in advance</p>