A-tisket a-tasket A green and yellow basket".length + 2 error

**I am trying to to return truncate string. It’s returned 5 tasks but error on **

"A-tisket a-tasket A green and yellow basket", 
"A-tisket a-tasket A green and yellow basket".length + 2

function truncateString(str, num) {
  // Clear out that junk in your trunk
  let result = "";
  for (let i=0; i<num; i++) {
    result += str[i];
  }
  if (num < str.length) {
    result = result + "...";
  } else if (num >= str.length) {
    result = result;
  }
 return result;
}

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

thank you very much for your response. I really appreciate it. :+1::+1::+1:

improve this with ternary if JavaScript — The Conditional (Ternary) Operator Explained | by Brandon Morelli | codeburst