JSFiddle - React, Tailwind, and code Playground

HTML

<div id="Str">I'm a string not too long but neither so short</div>

JavaScript

$("#Str").html(replacePiece($("#Str").text(), 13, 16));
    
    function replacePiece(str, start, end) {
       var component = str.substr(start, end - start);
       console.log(component);
       var newstr = str.substr(0,13) + "<b>" + component + "</b>"
          + str.substr(end);
       console.log(newstr);
       return newstr;
    }