const truncate = (string) => {
const newText = string.substring(0, 5);
return newText;
};
console.log(truncate("abcdefgh"));
//abcde
/**
* Check if an element is truncated.
*/
function isTruncated(el) {
return el.scrollWidth > el.clientWidth
}