Truncate a String Help Please

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(str.length<=num){
    return str;
  }
  
  var strSliced = str.slice(0,num);
  
  if(strSliced.length<=3){
    return strSliced + "...";
  }

  return strSliced.slice(0,-3) + "...";
}

Will someone please tell me what is wrong with this?!

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

I don’t know how to make it do that

I added some console.log to your code. If you open your browser console and run the tests you can see what the value of your strSliced variable is at various points in your function.

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(str.length<=num){
    return str;
  }
  
  var strSliced = str.slice(0,num);
  console.log("sliced string: " + strSliced)

  if(strSliced.length<=3){
    return strSliced + "...";
  }
  
  console.log("sliced string sliced again: " + strSliced.slice(0,-3) + "...")
  return strSliced.slice(0,-3) + "...";
}