Truncar um string-javascript

function truncateString(str, num) {
  return str.length > num ? str.slice(0, num) + "..." : str;
}
Angry Alpaca