title: Convert type string to type Text on Javascript
body: <p>I want to create a searcher on my website, the problem is that when I show the results of my database, some have a very large description and I'm trying to trunc the description in order to make it more visual.</p>
  
  <p>What I want to do is to show a description that should be like this:</p>
  
  <blockquote>
    <p>blablabla description bla bla bla more description</p>
  </blockquote>
  
  <p>into this:</p>
  
  <blockquote>
    <p>blablabla description bla bla bla mo...</p>
  </blockquote>
  
  <p>The maximum length that I want to show is 340 characters and the code that I was thinking of is this one</p>
  
  <pre><code>...
      var newText = document.createElement("p"); //i create a new element of text
      var newContent = document.createTextNode(projects.description); //i set the text to
          //be the description from the database [the type of this var is Text]
      if(newContent.length &gt; 340) {  //if the description is bigger than 340
           var result=newContent + "";  //i convert the newContent type to string since 
                //substring only works with strings and not Text
           result=result.substring(0, 337)+"...";  //i trunc the description
           newContent=result;  // &lt;-- here i need to assign the result[string] to newContent[Text]
      }
      newText.appendChild(newContent);
  ...
  </code></pre>
  
  <p>Hope you can tell me how to convert the string to Text again or another way to trunc the description.</p>
  
  <p>Thanks, Bertran</p>