Add characters to a string in Javascript

Bruno picture Bruno · Apr 22, 2011 · Viewed 399.9k times · Source

I need to add in a For Loop characters to an empty string. I know that you can use the function concat in Javascript to do concats with strings

var first_name = "peter"; 
var last_name = "jones"; 
var name=first_name.concat(last_name) 

but with my example it doesn't work. Any idea how to do it another way ?

my code :

    var text ="";
    for (var member in list) {
            text.concat(list[member]);
    }

Answer

Blazes picture Blazes · Apr 22, 2011
var text ="";
for (var member in list) {
        text += list[member];
}