You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classShopkeeper{talk(){// Return a randon item from the arrayconstwords=this.lines[Math.floor(Math.random()*this.lines.length)];console.log(words);}}Shopkeeper.prototype.lines=["Can I interest you in some wares?","Welcome, weary traveler"];
Problem
classShopkeeper{talk(){// Return a randon item from the arrayconstwords=this.lines[Math.floor(Math.random()*this.lines.length)];console.log(words);}}Shopkeeper.prototype.lines=["Can I interest you in some wares?","Welcome, weary traveler"];varartifactDealer=newShopkeeper();varclothingSeller=newShopkeeper();artifactDealer.lines=["Grumble, grumble."];clothingSeller.talk()// prints: ?
Problem
classShopkeeper{talk(){// Return a randon item from the arrayconstwords=this.lines[Math.floor(Math.random()*this.lines.length)];console.log(words);}}Shopkeeper.prototype.lines=["Can I interest you in some wares?","Welcome, weary traveler"];varartifactDealer=newShopkeeper();varclothingSeller=newShopkeeper();artifactDealer.lines.push("Grumble, grumble.");clothingSeller.talk()// prints: ?
Problem
classShopkeeper{talk(){// Return a randon item from the arrayconstwords=this.lines[Math.floor(Math.random()*this.lines.length)];console.log(words);}}Shopkeeper.prototype.lines=["Can I interest you in some wares?","Welcome, weary traveler"];varartifactDealer=newShopkeeper();varclothingSeller=newShopkeeper();artifactDealer.lines=["Grumble, grumble."];artifactDealer.talk()// prints: ?deleteartifactDealer.lines;artifactDealer.lines// prints: ?