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

6th
Nov 2015
Amir M.
@Wingedcross
Nov 06 2015 09:10

SPOILERS!
SPOILERS!
SPOILERS!

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

  else return (str.slice(0, num) + "...");

}

truncate("A-", 1);

This code works.