I am currently learning Object oriented Javascript but it seems that the alert is not working. what is the problem here?
<
html>
<head>
<script>
function professor(name, myLecture){
this.name = name;
this.myLecture = myLecture;
}
professor.prototype.display = function(){
return this.name + " is teaching " + this.myLecture;
};
function subjectList(subject){
this.subject = subject;
}
subjectList.prototype.showAll= function(){
var str = " " ;
for(var i = 0 ; i<subject.length; i++ )
str+= this.subject[i].display();
return str;
};
var ListOfSubs = new subjectList([
new professor("Muy","Obprog")
]);
alert(ListOfSubs.showAll());
</script>
<body>
</body>
</head>
</html>
Should be
this.subject.lengthinstead ofsubject.length.