--- id: 587d7dad367417b2b2512b77 title: Define a Constructor Function challengeType: 1 forumTopicId: 16804 localeTitle: Определение функции конструктора --- ## Description
Constructors - это функции, которые создают новые объекты. Они определяют свойства и поведение, которые будут принадлежать новому объекту. Подумайте о них как о плане создания новых объектов. Вот пример constructor :
функция Bird () {
this.name = "Альберт";
this.color = "blue";
this.numLegs = 2;
}
Этот constructor определяет объект Bird с name свойств, color и numLegs установленными на Albert, blue и 2, соответственно. Constructors следуют нескольким соглашениям:
## Instructions
Create a constructor, Dog, with properties name, color, and numLegs that are set to a string, a string, and a number, respectively.
## Tests
```yml tests: - text: Dog should have a name property set to a string. testString: assert(typeof (new Dog()).name === 'string'); - text: Dog should have a color property set to a string. testString: assert(typeof (new Dog()).color === 'string'); - text: Dog should have a numLegs property set to a number. testString: assert(typeof (new Dog()).numLegs === 'number'); ```
## Challenge Seed
```js ```
## Solution
```js function Dog (name, color, numLegs) { this.name = 'name'; this.color = 'color'; this.numLegs = 4; } ```