function Person(fullname, age) { this.fullname = fullname; this.age = age; } var people = []; function run_demo() { people.push(new Person("Johnny", 17)); people.push(new Person("Martin", 19)); people.push(new Person("Peter", 20)); var fullnames = people.filter(function (person) { return person.age >= 18; }).map(function (person) { return person.fullname; }); let res = document.getElementById("result"); let inner_text = ""; for (let item in fullnames) { inner_text += fullnames[item]; inner_text += "
"; } res.innerHTML = inner_text; }