📅  最后修改于: 2022-03-11 15:04:09.410000             🧑  作者: Mango
function truncateString(str, num) {
if (num > str.length){
return str;
} else{
str = str.substring(0,num);
return str+"...";
}
}
res = truncateString("A-tisket a-tasket A green and yellow basket", 11);
alert(res)