SyntaxFix
Write A Post
Hire A Developer
Questions
function truncate(input) { if (input.length > 5) { return input.substring(0, 5) + '...'; } return input; };
or in ES6
const truncate = (input) => input.length > 5 ? `${input.substring(0, 5)}...` : input;