Help with Confirm the ending

Hi,

I’m having troubles with this challenge.

From what I understood, the string variable should be matched to reflect the size of the target variable. I’m pasting my code and hope the get some help from you.

@rmdawson71 just gave you the answer. :slight_smile:
Hint: read how substr behaves with negative numbers as parameters.
confirmEnding() literally can be a one-line function.

Hi rmdawson71,

thank you for taking time for replying to my question.

When I posted on the forum it was bedtime for me and didn’t read your see your reply before morning (I believe we live in different time zones).

In any case, I actually managed to pass the challenge half an hour later by myself. However, I believe my implementation is very sub optimal and feels like I’m trying to cheat the FCC tests by making a tailored solution just to scrape the bottom of the barrell and go on instead of making a “universal” one. Furthermore, I noticed to use/think about a lot in if/else while many of these challenges could be solved way differently and better.

Here’s my code. I will take care to remove the link if it is needed.

Sorry for venting my thoughts to you but even though I’m passing these challenges so far, it feels like I’m not really advancing in learning how to solve problems in a more efficient way.

p.s.DId you actually post a one line solution and removed it later?

Thanks