Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add a letter to a string javascript

String.prototype.splice = function(idx, rem, str) {
    return this.slice(0, idx) + str + this.slice(idx + Math.abs(rem));
};

var result = "foo baz".splice(4, 0, "bar ");
document.body.innerHTML = result; // "foo bar baz"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #letter #string #javascript
ADD COMMENT
Topic
Name
4+2 =