andruhovski icon

Arrow-function (Initial Code)

andruhovski | PRO | 05/05/17 09:13:29 AM UTC | 0 ⭐ | 648 👁️ | Never ⏰ | []
JavaScript |

630 B

|

None

|

0 👍

/

0 👎

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 += "<br/>";
    }
    res.innerHTML = inner_text;
}

Comments