Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript add string to middle of string

function addStr(str, index, stringToAdd){
  return str.substring(0, index) + stringToAdd + str.substring(index, str.length);
}

let str = "This is a string";
let stringToAdd = "modyfied ";

console.log(addStr(str, 10, stringToAdd));  //outPut : "This is a modified string"
 
PREVIOUS NEXT
Tagged: #javascript #add #string #middle #string
ADD COMMENT
Topic
Name
8+9 =