Truncate a string (Basic Algorithm Scripting)

This works if I put an interger in the second slice position, but not if I use the arguement num. Why?

  **Your code so far**

function truncateString(str, num) {
let string = "...";
if (str.length < num){
string = str.slice(0, num) + string;
return string}
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; rv:94.0) Gecko/20100101 Firefox/94.0

Challenge: Truncate a String

Link to the challenge:

If I put:

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

at the bottom of your code, I get back:

A-tisket a-tasket A green and yellow basket

but I should get back:


I think you need to think about the logic on this line:

if (str.length < num){

I was able to change one thing and get your code to pass.

Sorted. I have a horrible block or greater than and less than and all of the memory tricks for it leave me more confused. Thanks again Kevin