Truncate a String- Not able to pass all the test cases

Tell us what’s happening:
I am not able to pass the first two test cases

Your code so far


function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length > num && num > 3) {
    return str.slice(0, (num - 3)) + '...';
  } else if (str.length > num && num <= 3) {
    return str.slice(0, num) + '...';
  } else {
    return str;
  }
}

truncateString("A-tisket a-tasket A green and yellow basket", 8);

The three dots are not included in the limite of characters, you have a statement that is not needed in your code

Truncate a string (first argument) if it is longer than the given maximumstring length (second argument). Return the truncated string with a ... ending.