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

30th
Jan 2016
Xavier Artot
@xavierartot
Jan 30 2016 03:55
I have another solution:
function truncate(str, num) {
  // Clear out that junk in your trunk
  var etc=3, dots='...';
  if (num === 1) {
    console.log(str = str.slice(0, 1) + dots);

  } else if(num > 1){

    if (num === 2) {
      console.log(str = str.slice(0,2) + dots);
    }else if (num <= 14){
      console.log(str = str.slice(0, num - 3 ) + dots);
    }else{
      console.log(str = str );
    }
  }
  return str;
}

truncate("A-tisket a-tasket A green and yellow basket", 11);
Xavier Artot
@xavierartot
Jan 30 2016 04:02
find tuncate
CamperBot
@camperbot
Jan 30 2016 04:02
find tuncate
nothing found