Skip to content
Advertisement

How to list array inside a javascript alert

I have an array of strings, I want to display the content with some html tags in the alert level. I tried this:

array = ["toto", "titi"]
alert("*" + array.join('n'))

but the problem here, I got only the first line with *. how can I resolvr this probleme to show all the lements with * in the begining ?

Advertisement

Answer

Using .concat() and .trim():

var arrStr =  ["toto","titi"];

alert([''].concat(arrStr).join('n*').trim());
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement