Search
 
SCRIPT & CODE EXAMPLE
 

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"
Comment

PREVIOUS NEXT
Code Example
Javascript :: once content is loaded run function 
Javascript :: javascript detect square number 
Javascript :: Playing sound in Vue.js 
Javascript :: getelementbyid 
Javascript :: javascript reverse array map 
Javascript :: javascript one off event listener 
Javascript :: jquery check input is disable 
Javascript :: Jquery Scroll on div using anchor tag is not Working properly 
Javascript :: npm ERR! 503 Service Unavailable: npm@latest 
Javascript :: js for of array with index 
Javascript :: jquery in react 
Javascript :: jquery redirect to another webpage 
Javascript :: min max and average finder in js array 
Javascript :: joi email validation regex 
Javascript :: FlatList Warning: Each child in a list should have a unique "key" prop. 
Javascript :: promises basic structure 
Javascript :: google charts hide legend 
Javascript :: edit json via nodejs 
Javascript :: passing data in react router history,push 
Javascript :: console log style 
Javascript :: JS class for each 
Javascript :: jquery set route with parameters in url 
Javascript :: validate json file programmatically in python 
Javascript :: angular bootstrap not working 
Javascript :: javascript array foreach example 
Javascript :: jasmine check if service was called only once 
Javascript :: mongodb instruction 
Javascript :: js get string byte size 
Javascript :: how to edit the link in a href with jquery 
Javascript :: javascript remove element from array 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =