string concatenation in js
var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
console.log(res);
string concatenation in js
var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
console.log(res);
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"
javascript string concatenation
var totn_string = '';
console.log(totn_string.concat('Tech','On','The','Net'));
//The following will be output to the web browser console log:
TechOnTheNet
how to assign char in a string javascript
function replaceAt(str, index, newChar) {
function replacer(origChar, strIndex) {
if (strIndex === index)
return newChar;
else
return origChar;
}
return str.replace(/./g, replacer);
}
let str = 'Hello World';
str = replaceAt(str, 1, 'u');
console.log(str); // Hullo World
Run code snippet
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us