freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../basic-javascript/accessing-nested-objects.ar...

2.3 KiB

id title challengeType guideUrl videoUrl localeTitle
56533eb9ac21ba0edf2244cc Accessing Nested Objects 1 https://arabic.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json الوصول إلى الكائنات المتداخلة

Description

يمكن الوصول إلى الخصائص الفرعية للكائنات عن طريق ربط صيغة النقطة أو القوس. هنا كائن متداخل:
var ourStorage = {
"مكتب": {
"الدرج": "دباسة"

"خزانة": {
"الدرج العلوي": {
"folder1": "ملف" ،
"folder2": "secrets"

"درج سفلي": "الصودا"
}

ourStorage.cabinet ["top drawer"]. // "أسرار"
ourStorage.desk.drawer. // "دباسة"

Instructions

قم بالوصول إلى كائن myStorage وقم بتعيين محتويات خاصية glove box إلى متغير gloveBoxContents . استخدام تدرج قوس للمواقع مع مساحة في أسمائهم.

Tests

tests:
  - text: يجب أن يساوي <code>gloveBoxContents</code> &quot;الخرائط&quot;
    testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
  - text: استخدم تدوين النقطة <code>myStorage</code> للوصول إلى <code>myStorage</code>
    testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'

Challenge Seed

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

var gloveBoxContents = undefined; // Change this line

After Test

console.info('after the test');

Solution

// solution required