Confirm the Ending
Check if a string (first argument, str
) ends with the given target string (second argument, target
).
This challenge can be solved with the .endsWith()
method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.
Tests
- Waiting: 1.
confirmEnding("Bastian", "n")
should returntrue
. - Waiting: 2.
confirmEnding("Congratulation", "on")
should returntrue
. - Waiting: 3.
confirmEnding("Connor", "n")
should returnfalse
. - Waiting: 4.
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")
should returnfalse
. - Waiting: 5.
confirmEnding("He has to give me a new name", "name")
should returntrue
. - Waiting: 6.
confirmEnding("Open sesame", "same")
should returntrue
. - Waiting: 7.
confirmEnding("Open sesame", "sage")
should returnfalse
. - Waiting: 8.
confirmEnding("Open sesame", "game")
should returnfalse
. - Waiting: 9.
confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")
should returnfalse
. - Waiting: 10.
confirmEnding("Abstraction", "action")
should returntrue
. - Waiting: 11. Your code should not use the built-in method
.endsWith()
to solve the challenge.
/** * Your test output will go here */