--- id: 587d824b367417b2b2512c47 title: Перевірте, чи визначено змінну або функцію challengeType: 2 forumTopicId: 301602 dashedName: test-if-a-variable-or-function-is-defined --- # --description-- Нагадуємо, що цей проєкт створюється на основі наступного початкового проєкту на [ Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) або копіюється з [ GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/). # --instructions-- У межах `tests/1_unit-tests.js` під тестом з міткою `#2` в наборі `Basic Assertions` змініть кожний `assert` на `assert.isDefined()` або `assert.isUndefined()` щоб полегшити проходження тесту (варто оцінювати як `true`). Не змінюйте аргументи, передані до тверджень. # --hints-- Всі тести повинні бути успішно пройдені. ```js (getUserInput) => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then( (data) => { assert.equal(data.state, 'passed'); }, (xhr) => { throw new Error(xhr.responseText); } ); ``` Потрібно обрати правильний метод для першого твердження `isDefined` або `isUndefined`. ```js (getUserInput) => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then( (data) => { assert.equal( data.assertions[0].method, 'isDefined', 'Null is not undefined' ); }, (xhr) => { throw new Error(xhr.responseText); } ); ``` Потрібно обрати правильний метод для другого твердження `isDefined` або `isUndefined`. ```js (getUserInput) => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then( (data) => { assert.equal( data.assertions[1].method, 'isUndefined', 'Undefined is undefined' ); }, (xhr) => { throw new Error(xhr.responseText); } ); ``` Потрібно обрати правильний метод для третього твердження `isDefined` або `isUndefined`. ```js (getUserInput) => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then( (data) => { assert.equal( data.assertions[2].method, 'isDefined', 'A string is not undefined' ); }, (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. */ ```