Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

2.1 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244c7 Accessing Object Properties with Dot Notation 1 使用点表示法访问对象属性

Description

有两种方法可以访问对象的属性:点表示法( . )和括号表示法( [] ),类似于数组。当您知道要提前访问的属性的名称时,使用点符号。以下是使用点表示法( . )读取对象属性的示例:
var myObj = {
prop1“val1”
prop2“val2”
};
var prop1val = myObj.prop1; // val1
var prop2val = myObj.prop2; // val2

Instructions

使用点表示法读入testObj的属性值。将变量hatValue设置为等于对象的属性hat ,并将变量shirtValue设置为等于对象的属性shirt

Tests

tests:
  - text: <code>hatValue</code>应该是一个字符串
    testString: assert(typeof hatValue === 'string' );
  - text: <code>hatValue</code>的值应该是<code>&quot;ballcap&quot;</code>
    testString: assert(hatValue === 'ballcap' );
  - text: <code>shirtValue</code>应该是一个字符串
    testString: assert(typeof shirtValue === 'string' );
  - text: <code>shirtValue</code>的值应该是<code>&quot;jersey&quot;</code>
    testString: assert(shirtValue === 'jersey' );
  - text: 你应该使用点符号两次
    testString: assert(code.match(/testObj\.\w+/g).length > 1);

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