function Student(name, gender, age) {
this.name = name;
this.gender = gender;
this.age = age;
}
Student.prototype.setSubject = function (subjectName) {
this.subject = subjectName;
}
Student.prototype.addMark = function (mark) {
if (this.marks === undefined) {
this.marks = mark;
} else {
this.marks.push(mark);
}
}
let student1 = new Student("Tony", "male", 37);
student1.setSubject("Algebra");
student1.addMark(5);
student1.addMark(4);
student1.addMark(5);
Почему в консоли выводит ошибку Uncaught TypeError: this.marks.push is not a function