Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript change string at particular index

function rep() {
    var str = 'Hello World';
    str = setCharAt(str,4,'a');
    alert(str);
}

function setCharAt(str,index,chr) {
    if(index > str.length-1) return str;
    return str.substring(0,index) + chr + str.substring(index+1);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #change #string #index
ADD COMMENT
Topic
Name
7+8 =