javascript task
-
Why doesn't this code work?
function Person(name){ this.name = name; }
Person.prototype.greet = function(otherName){
return "Hi " + otherName + ", my name is " + name;
}
-
Person.prototype.greet = function(otherName){ return "Hi " + otherName + ", my name is " + this.name; }
Key word missed this
var dave = new Person("Dave");
var hello = dave.greet("Alan"); // "Hi Alan, my name is Dave";