Display an array of texts using alert with line break in javascript


I have an array of string messages / texts and I want to display it using alert function in javascript. I managed to display them using join() function but I can not display them with line break at the end of each message / text and remove all the commas in between each text / message. Basically I want to display these texts like a list, below is my sample code:


What you did on your "test2" code is that you join all the texts and then added a break line at the end of it. Regarding the commas in between, you need to use the replace() function and regex to remove them. I believe what you are looking for this:

Copy and paste the code above in your browser console and press enter. It should display like a list.