Substring methods?

Tell us what’s happening:
The problem asks to use a substring methods instead of the endsWith() method.

Therefore i googled substring methods which gave me substring(). Therfore i understood i need to use substring.

Just to find out later that i can use slice() and what not like regex as shown in " get a hint".

well i think in my opinion the problem needs to be rewritten . Its upto your guys. Mentioning what exactly is wanted.

Further more i thought i just need to find a single letter instead of a word or words in the end of a string. Maybe because of the example used in the code where the string is a word and the target is just a single letter.

When i got the error, my reaction in short was “Ha!!?”

Though it took quite amount of my time. It was fun learning about substring and revising slice. And seeing the difference between the two. though there is still a third one substr().

  **Your code so far**

function confirmEnding(str, target) {
let lengthString = str.length;
let extractedString = str.substring(lengthString-1);

return extractedString == target ? true : false;
}

confirmEnding("Bastian", "n");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Challenge: Confirm the Ending

Link to the challenge:

I think the task description could definitely be slightly more specific on what is required(i do recall i was also unsure what a substring method meant exactly in the current context, when i first faced the challenge), but its nowhere near as confusing and lacking as you describe it. If we are to read it literally, nowhere they say use the substring method, or substring(), instead they use discriptive word to suggest any substring methed, i.e. method that grabs part of a string, while being explicit not to use endsWith() as it makes it quite easy. Coming from the past lessons, you should also be on the page with slice, and its natural this method to be among the first you consider/recall for the matter. Also, its easy to check on the test examples, to get a much better idea of what it is required of you. In the current case, there are quite the number of examples that tells you need to look for an entire sub-string, not just a letter.
Anyway, like you figured out, the time you spent was worth it, as you found out about regex and other possible methods to solve that task. Next time you find yourself needing to get the final letters of a string, you’ll have 4-5 methods prepared under your belt ^^