From 1b69bbdaef4d17b5ed1b888f930f06e5cd53bec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lasse=20J=C3=B8rgensen?= <28780271+lasjorg@users.noreply.github.com> Date: Fri, 5 May 2023 13:25:38 +0200 Subject: [PATCH] fix(curriculum): Be more explicit about using parameters (#50269) --- .../testing-objects-for-properties.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.md index 41d06868e9c..e7b68bac781 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties.md @@ -8,25 +8,24 @@ dashedName: testing-objects-for-properties # --description-- -Sometimes it is useful to check if the property of a given object exists or not. We can use the `.hasOwnProperty(propname)` method of objects to determine if that object has the given property name. `.hasOwnProperty()` returns `true` or `false` if the property is found or not. +To check if a property on a given object exists or not, you can use the `.hasOwnProperty()` method. `someObject.hasOwnProperty(someProperty)` returns `true` or `false` depending on if the property is found on the object or not. **Example** ```js -const myObj = { - top: "hat", - bottom: "pants" -}; +function checkForProperty(object, property) { + return object.hasOwnProperty(property); +} -myObj.hasOwnProperty("top"); -myObj.hasOwnProperty("middle"); +checkForProperty({ top: 'hat', bottom: 'pants' }, 'top'); // true +checkForProperty({ top: 'hat', bottom: 'pants' }, 'middle'); // false ``` -The first `hasOwnProperty` returns `true`, while the second returns `false`. +The first `checkForProperty` function call returns `true`, while the second returns `false`. # --instructions-- -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"`. +Modify the function `checkObj` to test if the object passed to the function parameter `obj` contains the specific property passed to the function parameter `checkProp`. If the property passed to `checkProp` is found on `obj`, return that property's value. If not, return `Not Found`. # --hints--