jsartisan / frontend-challenges

FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
https://frontend-challenges.com
27 stars 4 forks source link

115 - forEach and this - javascript #128

Open jsartisan opened 2 months ago

jsartisan commented 2 months ago

index.js

let group = {
  title: "Our Group",
  students: ["John", "Pete", "Alice"],

  showList() {
    const that = this;

    this.students.forEach(function(student) {
      console.log(that.title + ': ' + student);
    });
  }
};

export { group };