These are chat archives for camperbot/bonfire-truncate-a-string

30th
Oct 2015
ipero
@ipero
Oct 30 2015 04:06
No, the above code doesn't pass. Here is correct code:
function truncate(str, num) {
  // Clear out that junk in your trunk
  if (str.length<4){
    return str.slice(0,num)+"...";
  }
  else if(str.length<=num){
    return str;
  }
  else{
  return str.slice(0,num-3)+"...";
  }
}

truncate("A-tisket a-tasket A green and yellow basket", 11);