pick your poison ...
you can also use array.foreach ...
function start() {
var arrPeople = ['Adele', 'Ted', 'Jo', 'Jim', 'Emma', 'Kate', 'Christopher'];
var text = '';
arrPeople.forEach(function(person) {
text += person + '<br />';
});
}
see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
here's an possibly an even simpler solution using array.join ...
function start() {
var arrPeople = ['Adele', 'Ted', 'Jo', 'Jim', 'Emma', 'Kate', 'Christopher'];
var text = arrPeople.join("<br />");
text += "<br />";
}
see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
or if you prefer, you can also use the functional style using array.reduce ...
function start() {
var arrPeople = ['Adele', 'Ted', 'Jo', 'Jim', 'Emma', 'Kate', 'Christopher'];
var text = arrPeople.reduce(function(txt, itm) {
return txt + '<br />' + itm;
})
text += "<br />";
}
see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
<br/>tag you can also use thistext= arrPeople.toString().replace(new RegExp(',', 'g'), '<br/>').