diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.english.md index 36eed3f7a8..026a5c1d92 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.english.md @@ -24,7 +24,7 @@ myObj.hasOwnProperty("middle"); // false ## Instructions
-Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found". +Modify the function checkObj to test if an object passed to the function (obj) contains a specific property (checkProp). If the property is found, return that property's value. If not, return "Not Found".
## Tests @@ -32,13 +32,16 @@ Modify the function checkObj to test myObj for c ```yml tests: - - text: checkObj("gift") should return "pony". - testString: assert(checkObj("gift") === "pony"); - - text: checkObj("pet") should return "kitten". - testString: assert(checkObj("pet") === "kitten"); - - text: checkObj("house") should return "Not Found". - testString: assert(checkObj("house") === "Not Found"); - + - text: 'checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") should return "pony".' + testString: 'assert(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") === "pony");' + - text: 'checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet") should return "kitten".' + testString: 'assert(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet") === "kitten");' + - text: 'checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house") should return "Not Found".' + testString: 'assert(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house") === "Not Found");' + - text: 'checkObj({city: "Seattle"}, "city") should return "Seattle".' + testString: 'assert(checkObj({city: "Seattle"}, "city") === "Seattle");' + - text: 'checkObj({city: "Seattle"}, "district") should return "Not Found".' + testString: 'assert(checkObj({city: "Seattle"}, "district") === "Not Found");' ``` @@ -56,13 +59,13 @@ var myObj = { bed: "sleigh" }; -function checkObj(checkProp) { +function checkObj(obj, checkProp) { // Only change code below this line return "Change Me!"; // Only change code above this line } -checkObj("gift"); +checkObj(myObj, "gift"); ``` @@ -81,9 +84,9 @@ var myObj = { pet: "kitten", bed: "sleigh" }; -function checkObj(checkProp) { - if(myObj.hasOwnProperty(checkProp)) { - return myObj[checkProp]; +function checkObj(obj, checkProp) { + if(obj.hasOwnProperty(checkProp)) { + return obj[checkProp]; } else { return "Not Found"; }