Truncate a string close but not quite

Can’t quite figure what’s missing, any insight would be appreciated, thanks in advance.

function truncateString(str, num) {
  if (str.length <= num){
    return str.slice(0, num) + "...";
  } else if (str.length > num) {
    return str.slice(0, num-3) + "...";
  } else {
  return str;

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

The way I did it, I made a three-way fork. I returned a value if str.length <= num, another value if num <= 3, and yet another for all other cases.