Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.3 KiB
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7dac367417b2b2512b74 使用点符号来访问对象的属性 1 301333 use-dot-notation-to-access-the-properties-of-an-object

--description--

在上一个挑战中,我们创建了一个拥有不同属性对象,现在我们来看看该如何访问这些属性

let duck = {
  name: "Aflac",
  numLegs: 2
};
console.log(duck.name);
// 这段代码会在控制台中输出 "Aflac"

我们可以用“点号表示法”来访问对象的属性,只需要在对象名称后面加上.以及属性名即可。比如,duck.name就可以访问到 "Aflac"。

--instructions--

请在控制台里面输出dog对象中两个属性对应的值。

--hints--

你应该使用console.log来将dog对象的name属性值输出到控制台。

assert(/console.log\(.*dog\.name.*\)/g.test(code));

你应该使用console.log来将dog对象的numLegs属性值输出到控制台。

assert(/console.log\(.*dog\.numLegs.*\)/g.test(code));

--seed--

--seed-contents--

let dog = {
  name: "Spot",
  numLegs: 4
};
// Only change code below this line

--solutions--

let dog = {
  name: "Spot",
  numLegs: 4
};
console.log(dog.name);
console.log(dog.numLegs);