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.0 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7dad367417b2b2512b77 Define a Constructor Function 1 定义构造函数

Description

Constructors函数是创建新对象的函数。它们定义属于新对象的属性和行为。将它们视为创建新对象的蓝图。以下是constructor的示例:
function Bird{
this.name =“阿尔伯特”;
this.color =“blue”;
this.numLegs = 2;
}
constructor定义一个Bird对象,其属性name colornumLegs设置为Albertblue和2。 Constructors遵循一些约定:
  • Constructors函数使用大写名称定义,以区别于非constructors函数的其他函数。
  • Constructors使用关键字this来设置它们将创建的对象的属性。在constructor this指的是它将创建的新对象。
  • Constructors定义属性和行为,而不是像其他函数那样返回值。

Instructions

创建一个constructor Dog ,其属性name colornumLegs分别设置为字符串,字符串和数字。

Tests

tests:
  - text: <code>Dog</code>应该将<code>name</code>属性设置为字符串。
    testString: assert(typeof (new Dog()).name === 'string');
  - text: <code>Dog</code>应该将<code>color</code>属性设置为字符串。
    testString: assert(typeof (new Dog()).color === 'string');
  - text: <code>Dog</code>应该将<code>numLegs</code>属性设置为数字。
    testString: assert(typeof (new Dog()).numLegs === 'number');

Challenge Seed


Solution

// solution required