Advertisement
andruhovski

Arrow-function (Initial Code)

May 5th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Person(fullname, age) {
  2.     this.fullname = fullname;
  3.     this.age = age;
  4. }
  5. var people = [];
  6.  
  7. function run_demo() {
  8.     people.push(new Person("Johnny", 17));
  9.     people.push(new Person("Martin", 19));
  10.     people.push(new Person("Peter", 20));
  11.     var fullnames = people.filter(function (person) {
  12.         return person.age >= 18;
  13.     }).map(function (person) {
  14.         return person.fullname;
  15.     });
  16.     let res = document.getElementById("result");
  17.     let inner_text = "";
  18.     for (let item in fullnames) {
  19.         inner_text += fullnames[item];
  20.         inner_text += "<br/>";
  21.     }
  22.     res.innerHTML = inner_text;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement