Любая помощь с этим будет принята с благодарностью. Я просто не могу понять это, хотя чувствую, что код, который я пробую, верен. Это дает мне ошибку, что sayName
и takeAttendance
не являются функциями. Заранее спасибо!
Вот что я пытаюсь:
function Cohort(program, campus, number, students=['Bill', 'Ted', 'Bob']) {
this.program = program;
this.campus = campus;
this.number = number;
this.students = students;
this.sayName = function() {
return 'This cohort is called ' + this.program + this.campus + this.number;
}
this.takeAttendance = function() {
console.log(this.students);
}
}
cohort1 = {
program: 'w',
campus: 'pr',
number: 27,
students: ['Preston', 'Katie', 'Chester']
}
cohort2 = {
program: 'w',
campus: 'pr',
number: 31,
students: ['Brendan Eich', 'Dan Abramov', 'Wes Bos', 'Kent Dodds', 'Billy Bob']
}
cohort1.sayName();
cohort2.takeAttendance();