...
Solution Review: Prototype Property
This lesson will explain the solution to the problem in the previous lesson.
In the previous lesson, you were given the following code to modify.
function func1(name){ this.name = name;}var obj1 = new func1("Bran");func1.prototype = { talk: function(){ console.log ("Welcome " + this.name); }}function display(){ var obj2 = new func1("Jon"); obj2.talk() // works obj1.talk() // doesn't work}display()
function func1(name){ this.name = name;}var obj1 = new func1("Bran");func1.prototype.talk = function(){ console.log ("Welcome " + this.name);}function display(){ var obj2 = new func1("Jon"); obj2.talk() obj1.talk() }display()
This challenge tests your ...