--- id: acda2fb1324d9b0fa741e6b5 title: Confirm the Ending isRequired: true challengeType: 5 videoUrl: '' localeTitle: Подтвердить завершение --- ## Description <section id="description"> Проверьте, заканчивается ли строка (первый аргумент, <code>str</code> ) заданной целевой строкой (второй аргумент, <code>target</code> ). Эта проблема <em>может</em> быть решена с помощью <code>.endsWith()</code> , который был введен в ES2015. Но для этой задачи мы хотели бы, чтобы вы использовали один из методов подстроки JavaScript. Не забудьте использовать <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask,</a> если вы застряли. Напишите свой собственный код. </section> ## Instructions <section id="instructions"> </section> ## Tests <section id='tests'> ```yml tests: - text: '<code>confirmEnding("Bastian", "n")</code> должен возвращать true.' testString: 'assert(confirmEnding("Bastian", "n") === true, "<code>confirmEnding("Bastian", "n")</code> should return true.");' - text: '<code>confirmEnding("Congratulation", "on")</code> должно возвращать true.' testString: 'assert(confirmEnding("Congratulation", "on") === true, "<code>confirmEnding("Congratulation", "on")</code> should return true.");' - text: '<code>confirmEnding("Connor", "n")</code> должен возвращать значение false.' testString: 'assert(confirmEnding("Connor", "n") === false, "<code>confirmEnding("Connor", "n")</code> should return false.");' - text: '<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> должны возвращать значение false.' testString: 'assert(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") === false, "<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> should return false.");' - text: '<code>confirmEnding("He has to give me a new name", "name")</code> должен возвращать true.' testString: 'assert(confirmEnding("He has to give me a new name", "name") === true, "<code>confirmEnding("He has to give me a new name", "name")</code> should return true.");' - text: '<code>confirmEnding("Open sesame", "same")</code> должен возвращать true.' testString: 'assert(confirmEnding("Open sesame", "same") === true, "<code>confirmEnding("Open sesame", "same")</code> should return true.");' - text: '<code>confirmEnding("Open sesame", "pen")</code> должен возвращать false.' testString: 'assert(confirmEnding("Open sesame", "pen") === false, "<code>confirmEnding("Open sesame", "pen")</code> should return false.");' - text: '<code>confirmEnding("Open sesame", "game")</code> должен возвращать значение false.' testString: 'assert(confirmEnding("Open sesame", "game") === false, "<code>confirmEnding("Open sesame", "game")</code> should return false.");' - text: '<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> должны возвращать ложные.' testString: 'assert(confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain") === false, "<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> should return false.");' - text: '<code>confirmEnding("Abstraction", "action")</code> должно возвращать true.' testString: 'assert(confirmEnding("Abstraction", "action") === true, "<code>confirmEnding("Abstraction", "action")</code> should return true.");' - text: Не используйте встроенный метод <code>.endsWith()</code> чтобы решить проблему. testString: 'assert(!(/\.endsWith\(.*?\)\s*?;?/.test(code)) && !(/\["endsWith"\]/.test(code)), "Do not use the built-in method <code>.endsWith()</code> to solve the challenge.");' ``` </section> ## Challenge Seed <section id='challengeSeed'> <div id='js-seed'> ```js function confirmEnding(str, target) { // "Never give up and good luck will find you." // -- Falcor return str; } confirmEnding("Bastian", "n"); ``` </div> </section> ## Solution <section id='solution'> ```js // solution required ``` </section>