JSFiddle - React, Tailwind, and code Playground
JavaScript
var str = "The Hello World Code!";
var newStr="Hi"
// outputs "The Hi World Code"
var startIndex= 4; // start index of 'H' from 'Hello'
var endIndex= 8; // end index of 'o' from 'Hello'
var preStr = str.substring(0, startIndex);
var postStr = str.substring(endIndex+1, str.length - 1);
var result = preStr+newStr+postStr;
alert(result)