10 lines
153 B
JavaScript
10 lines
153 B
JavaScript
function truncate(str, num) {
|
|
if (str.length > num) {
|
|
return str.slice(0, num) + "...";
|
|
} else {
|
|
return str;
|
|
}
|
|
}
|
|
|
|
export default truncate;
|