Truncate a String-need help

Tell us what’s happening:

Your code so far


function truncateString(str, num) {
  // Clear out that junk in your trunk
  var str1=str.slice(0,num);
  str=console.log(str1+"...");
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 8);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/truncate-a-string/

If you do this, str is undefined…

Also, if the string doesn’t go over the character limit you shouldn’t add the dots

function truncateString(str, num) {
// Clear out that junk in your trunk
var str1=str.slice(0,num);
var str2=console.log(str1+"…");

return str=str2;
}

truncateString(“A-tisket a-tasket A green and yellow basket”, 8);
what about this one?

Same thing, console.log() returns undefined, so str2 is undefined