diff --git a/challenges/02-javascript-algorithms-and-data-structures/object-oriented-programming.json b/challenges/02-javascript-algorithms-and-data-structures/object-oriented-programming.json
index b963727492..5f1c7d949f 100644
--- a/challenges/02-javascript-algorithms-and-data-structures/object-oriented-programming.json
+++ b/challenges/02-javascript-algorithms-and-data-structures/object-oriented-programming.json
@@ -432,12 +432,12 @@
"description": [
"There is a special constructor
property located on the object instances duck
and beagle
that were created in the previous challenges:",
"
let duck = new Bird();", - "Note that the
let beagle = new Dog();
console.log(duck.constructor === Bird); //prints true
console.log(beagle.constructor === Dog); //prints true
constructor
property is the name of the constructor function that created the instance.",
+ "Note that the constructor
property is a reference to the constructor function that created the instance.",
"The advantage of the constructor
property is that it's possible to check for this property to find out what kind of object it is. Here's an example of how this could be used:",
"function joinBirdFraternity(candidate) {", "Note
if (candidate.constructor === Bird) {
return true;
} else {
return false;
}
}
constructor
property can be overwritten (which will be covered in the next two challenges) it’s generally better to use the instanceof
method to check the type of an object.",
"joinDogFraternity
function that takes a candidate
parameter and returns true
if the candidate is a Dog
and returns false
otherwise."
+ "Write a joinDogFraternity
function that takes a candidate
parameter and, using the constructor
property, return true
if the candidate is a Dog
, otherwise return false
."
],
"challengeSeed": [
"function Dog(name) {",
@@ -452,7 +452,8 @@
],
"tests": [
"assert(typeof(joinDogFraternity) === 'function', 'message: joinDogFraternity
should be defined as a function.');",
- "assert(joinDogFraternity(new Dog(\"\")) === true, 'message: joinDogFraternity
should return true ifcandidate
is an instance of Dog
.');"
+ "assert(joinDogFraternity(new Dog(\"\")) === true, 'message: joinDogFraternity
should return true ifcandidate
is an instance of Dog
.');",
+ "assert(/\\.constructor/.test(code) && !/instanceof/.test(code), 'message: joinDogFraternity
should use the constructor
property.');"
],
"solutions": [
"function Dog(name) {\n this.name = name;\n}\nfunction joinDogFraternity(candidate) {\n return candidate.constructor === Dog;\n}"