title: Truncate a string JavaScript
body: <p>My task is to "truncate a string (first argument), if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.</p>
  
  <p>Note that inserting the three dots to the end will add to the string length.</p>
  
  <p>However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string."</p>
  
  <p>I have written the code: </p>
  
  <pre><code>function truncateString(str, num) {
    if (num &gt; str.length){
      str.slice(num);
      return str.append("...");
    } 
    else if (num &lt; 3) {
      str.slice(3);
      return str.append("...");
    }
    else {
      return "This is not a string";
    }
  
  }
  
  truncateString("A-tisket a-tasket A green and yellow basket", 11);
  </code></pre>
  
  <p>However, it's not doing what I need it to do and returns "This is not a string" on every run. Can anyone help me? </p>