mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-31 15:03:21 -05:00
2.3 KiB
2.3 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244c7 | الوصول إلى خصائص الكائن مع النقطة التأشير (Accessing Object Properties with Dot Notation) | 1 | https://scrimba.com/c/cGryJs8 | 16164 | accessing-object-properties-with-dot-notation |
--description--
هناك طريقتان للوصول إلى خصائص الكائن: نقطة التأشير (.) وتدوين الأقواس ([])، على غرار القائمة.
ترميز النقطة هو ما تستخدمه عندما تعرف اسم الخاصية التي تحاول الوصول إليها مسبقاً.
هذا مثال من استخدام النقطة التأشير (.) لقراءة خاصية الكائن:
const myObj = {
prop1: "val1",
prop2: "val2"
};
const prop1val = myObj.prop1;
const prop2val = myObj.prop2;
سيكون إلى prop1val قيمة نص val1، و سيكون إلى prop2val قيمة نص val2.
--instructions--
اقرأ في قيم الخاصية testObj باستخدام النقطة التأشير. عيّن المتغير hatValue مساوية لخاصية الكائن hat, وعيّن المتغير shirtValue مساوية لخاصية الكائن shirt.
--hints--
قيمة hatVvalue يجب أن تكون نص
assert(typeof hatValue === 'string');
يجب أن تكون قيمة hatValue نص ballcap
assert(hatValue === 'ballcap');
يجب أن تكون قيمة shirtValue نص
assert(typeof shirtValue === 'string');
يجب أن تكون قيمة shirtValue نص jersey
assert(shirtValue === 'jersey');
يجب عليك استخدام النقطة التأشير مرتين
assert(code.match(/testObj\.\w+/g).length > 1);
--seed--
--after-user-code--
(function(a,b) { return "hatValue = '" + a + "', shirtValue = '" + b + "'"; })(hatValue,shirtValue);
--seed-contents--
// Setup
const testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};
// Only change code below this line
const hatValue = testObj; // Change this line
const shirtValue = testObj; // Change this line
--solutions--
const testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};
const hatValue = testObj.hat;
const shirtValue = testObj.shirt;