JSFiddle - React, Tailwind, and code Playground
HTML
<a id="result-location" href='test'>
<script>
window.onload = function(){setTimeout(function () {
document.getElementById('result-location').innerHTML = truncate("truncate this text");
},1);};
</script>
</a>
JavaScript
function truncate(string) {
return (string.length > 5) ? string.substring(0, 5) + '...' : string;
};