Question:

Use the teamCity() function and teams array to create the following array ['Giants from New York', 'Seahawks from Seattle'].

function Team(name, city) {
  this.name = name;
  this.city = city;
}

teams = [
  new Team("Giants", "New York"),
  new Team("Seahawks", "Seattle")
]

function teamCity () {
  return this.name + " from " + this.city;
}

Answer:

result = []
teams.forEach(function (team) {
  result.push(teamCity.call(team));
});
console.log(result);

Keywords:

© 2017 QuizBucket.org