Проверьте, заканчивается ли строка (первый аргумент, <code>str</code> ) заданной целевой строкой (второй аргумент, <code>target</code> ). Эта проблема <em>может</em> быть решена с помощью <code>.endsWith()</code> , который был введен в ES2015. Но для этой задачи мы хотели бы, чтобы вы использовали один из методов подстроки JavaScript. Не забудьте использовать <ahref="https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514"target="_blank">Read-Search-Ask,</a> если вы застряли. Напишите свой собственный код.
- text: <code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> should return false.
testString: assert(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") === false);
- text: <code>confirmEnding("He has to give me a new name", "name")</code> should return true.
testString: assert(confirmEnding("He has to give me a new name", "name") === true);
- text: <code>confirmEnding("Open sesame", "same")</code> should return true.
- 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> should return false.
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);
- text: <code>confirmEnding("Abstraction", "action")</code> should return true.