function Student() {
}
Student.prototype.sayName = function() {
console.log(this.name)
}
function EighthGrader(name) {
this.name = name
this.grade = 8
}
EighthGrader.prototype = Student.prototype
function NinthGrader(name) {
this.name = name
this.grade = 9
}
NinthGrader.prototype = Student.prototype
NinthGrader.prototype.sayName = function() {console.log("HAHAHAHAHAHA")}
const carl = new EighthGrader("carl")
carl.sayName()
I tried to read the MDN Documentation of Object.create() and i wasn't able to figure out why does console.log(carl.sayName());print "HAHAHAHAHAHA"and not "carl" when i added a method to the prototype object of the NinthGrader object.