In JavaScript, concat() is a string method that is used to concatenate strings together. The concat() method appends one or more string values to the calling string and then returns the concatenated result as a new string.
You can simply use + operator to add character to String in Javascript. As you can see, we have added char 't' to var str using + operator at the end.
let text = "";
for(let member in list) {
text += list[member];
}
You can also keep adding strings to an existing string like so:
var myString = "Hello ";
myString += "World";
myString += "!";
the result would be -> Hello World!
simply used the +
operator. Javascript concats strings with +
To use String.concat, you need to replace your existing text, since the function does not act by reference.
let text = "";
for (const member in list) {
text = text.concat(list[member]);
}
Of course, the join() or += suggestions offered by others will work fine as well.
It sounds like you want to use join
, e.g.:
var text = list.join();
Simple use text = text + string2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With