append a string to the end of another string in javascript

To append a string to the end of another string in JavaScript, you can use the concatenation operator + to join the two strings together.

Here is an example:

let str1 = "Hello, ";
let str2 = "world!";
let result = str1 + str2;
console.log(result); // Output: "Hello, world!"
117 chars
5 lines

Alternatively, you can use the concat() method like this:

let str1 = "Hello, ";
let str2 = "world!";
let result = str1.concat(str2);
console.log(result); // Output: "Hello, world!"
123 chars
5 lines

Note that the concat() method can also take multiple arguments if you want to concatenate more than two strings together.

gistlibby LogSnag