From c1b3588e5922a474ace13f36ea836e5754e74fea Mon Sep 17 00:00:00 2001 From: Kiara Barias <33493552+Kbarias@users.noreply.github.com> Date: Mon, 25 Nov 2019 14:02:21 -0500 Subject: [PATCH] Basic JS challenge: use-prototype-properties link added (#37802) * Update use-prototype-properties-to-reduce-duplicate-code.english.md * Update use-prototype-properties-to-reduce-duplicate-code.english.md --- ...se-prototype-properties-to-reduce-duplicate-code.english.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code.english.md index 913dd2e6d2..6c0eb351d7 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code.english.md @@ -9,7 +9,7 @@ forumTopicId: 301336
Since numLegs will probably have the same value for all instances of Bird, you essentially have a duplicated variable numLegs inside each Bird instance. This may not be an issue when there are only two instances, but imagine if there are millions of instances. That would be a lot of duplicated variables. -A better way is to use Bird’s prototype. The prototype is an object that is shared among ALL instances of Bird. Here's how to add numLegs to the Bird prototype: +A better way is to use Bird’s prototype. Properties in the prototype are shared among ALL instances of Bird. Here's how to add numLegs to the Bird prototype: ```js Bird.prototype.numLegs = 2; @@ -26,6 +26,7 @@ Since all instances automatically have the properties on the prototypeprototype for duck and canary is part of the Bird constructor as Bird.prototype. Nearly every object in JavaScript has a prototype property which is part of the constructor function that created it.
+ ## Instructions
Add a numLegs property to the prototype of Dog