From 9051ad2eb5719d09e04197cc96aa3205b024a3ad Mon Sep 17 00:00:00 2001 From: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Date: Sun, 17 Mar 2019 15:47:41 -0700 Subject: [PATCH] Fixed bug allowing versions of Object.keys method and hard coding of ownProps array (#35021) * fix: disallow variants of Object.keys method * fix: added new test to help prevent hardcoding array * fix: refactored regex --- .../understand-own-properties.english.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.english.md index 9bb5134dac5..6c21fe75276 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.english.md @@ -25,9 +25,11 @@ Add the own properties of canary to the array ow ```yml tests: - text: ownProps should include the values "numLegs" and "name". - testString: assert(ownProps.indexOf('name') !== -1 && ownProps.indexOf('numLegs') !== -1, 'ownProps should include the values "numLegs" and "name".'); + testString: assert(ownProps.indexOf('name') !== -1 && ownProps.indexOf('numLegs') !== -1); - text: Solve this challenge without using the built in method Object.keys(). - testString: assert(!/\Object.keys/.test(code), 'Solve this challenge without using the built in method Object.keys().'); + testString: assert(!/Object(\.keys|\[(['"`])keys\2\])/.test(code)); + - text: Solve this challenge without hardcoding the ownProps array. + testString: assert(!/\[\s*(?:'|")(?:name|numLegs)|(?:push|concat)\(\s*(?:'|")(?:name|numLegs)/.test(code)); ```