freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../basic-javascript/accessing-object-properties...

2.7 KiB

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244c7 Accessing Object Properties with Dot Notation 1 الوصول إلى خصائص كائن مع ترميز Dot

Description

هناك طريقتان للوصول إلى خصائص كائن: تدوين نقطي ( . ) وتدوين قوس ( [] ) ، شبيه بصفيف. Dot notation هو ما تستخدمه عندما تعرف اسم العقار الذي تحاول الوصول إليه في وقت مبكر. هنا عينة من استخدام تدوين النقطة ( . ) لقراءة خاصية الكائن:
var myObj = {
prop1: "val1" ،
prop2: "val2"

var prop1val = myObj.prop1 ، // val1
var prop2val = myObj.prop2؛ // val2

Instructions

قراءة في قيم خاصية testObj باستخدام التدوين النقطي. تعيين hatValue متغير يساوي hat خاصية الكائن وتعيين shirtValue متغير shirtValue يساوي shirt خاصية الكائن.

Tests

tests:
  - text: يجب أن يكون <code>hatValue</code> سلسلة
    testString: 'assert(typeof hatValue === "string" , "<code>hatValue</code> should be a string");'
  - text: قيمة <code>hatValue</code> يجب أن تكون <code>&quot;ballcap&quot;</code>
    testString: 'assert(hatValue === "ballcap" , "The value of <code>hatValue</code> should be <code>"ballcap"</code>");'
  - text: يجب أن يكون <code>shirtValue</code> عبارة عن سلسلة
    testString: 'assert(typeof shirtValue === "string" , "<code>shirtValue</code> should be a string");'
  - text: يجب أن تكون قيمة <code>shirtValue</code> <code>&quot;jersey&quot;</code>
    testString: 'assert(shirtValue === "jersey" , "The value of <code>shirtValue</code> should be <code>"jersey"</code>");'
  - text: يجب عليك استخدام dot notation مرتين
    testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'

Challenge Seed

// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj;      // Change this line
var shirtValue = testObj;    // Change this line

After Test

console.info('after the test');

Solution

// solution required