Open Emperor01 opened 6 years ago
function truncate (str, maxlength) { if (str.length > maxlength) { str = str.slice(0, maxlength - 3) + "..."; }
return str; }
alert(truncate('I buy some apples to myself', 20));
function truncate (str, maxlength) { if (str.length > maxlength) { str = str.slice(0, maxlength - 3) + "..."; }
return str; }
alert(truncate('I buy some apples to myself', 20));