Files

116 lines
3.4 KiB
Markdown
Raw Permalink Normal View History

---
id: 587d824e367417b2b2512c57
title: Перевірка об'єкта на екземпляр конструктора
challengeType: 2
forumTopicId: 301605
dashedName: test-if-an-object-is-an-instance-of-a-constructor
---
# --description--
Нагадуємо, що цей проєкт створено на основі наступного стартового проєкту [ Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai), або кальковано з [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
`#instanceOf` стверджує, що об'єкт є екземпляром конструктора.
# --instructions--
У межах `tests/1_unit-tests.js` під тестом з міткою `#18` в наборі `Objects` змініть кожний `assert` на `assert.instanceOf` або `assert.notInstanceOf`, щоб забезпечити проходження тесту (має мати значення `true`). Не змінюйте аргументи, передані до тверджень.
# --hints--
Всі тести повинні бути успішно пройдені.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Потрібно обрати правильний метод для першого твердження `instanceOf` або `notInstanceOf`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
(data) => {
assert.equal(
data.assertions[0].method,
'notInstanceOf',
'myCar is not an instance of Plane'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Потрібно обрати правильний метод для другого твердження `instanceOf` або `notInstanceOf`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
(data) => {
assert.equal(
data.assertions[1].method,
'instanceOf',
'airlinePlane is an instance of Plane'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Потрібно обрати правильний метод для третього твердження `instanceOf` або `notInstanceOf`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
(data) => {
assert.equal(
data.assertions[2].method,
'instanceOf',
'everything is an Object in JavaScript...'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Потрібно обрати правильний метод для четвертого твердження `instanceOf` або `notInstanceOf`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
(data) => {
assert.equal(
data.assertions[3].method,
'notInstanceOf',
'myCar.wheels is not an instance of String'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
# --solutions--
```js
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/
```