// Truncate a string

// Truncate a string (first argument) if it is longer than the given maximum string length (second argument). 
// Return the truncated string with a ... ending.

// Note that inserting the three dots to the end will add to the string length.

// However, if the given maximum string length num is less than or equal to 3, 
// then the addition of the three dots does not add to the string length in determining the truncated string.

/**
 * @param {string} str
 * @return {string}
 */

@@ -500,8 +500,251 @@
 ng%7D%0A */%0A
+%0A%0Afunction truncateString(str, num) %7B%0A  if (str.length %3E num) %7B%0A  %09return num %3C 3 ? str.slice(0, num) + '...' : str.slice(0, num - 3) + '...';%0A  %7D%0A  return str;%0A%7D%0A%0Aconsole.log9truncateString(%22A-tisket a-tasket A green and yellow basket%22, 11));

add solution