JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <th>Mathematics</th>
    <th>Science</th>
    <th>Arts</th>    
</table>

JavaScript

$(document).ready(function() {
   
    $("table th").each(function() {
        var text = $(this).text();
        if (text.length > 7) {
           $(this).text(text .slice(0,7) + "...");
        }

    });
    
});