# Help with Confirm the ending

**URL:** <https://forum.freecodecamp.org/t/help-with-confirm-the-ending/104594>\
**Category:** General\
**Created:** [April 9, 2017, 11:01pm UTC](https://forum.freecodecamp.org/t/help-with-confirm-the-ending/104594 "2017-04-09T23:01:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlessioNovi](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@AlessioNovi](https://forum.freecodecamp.org/u/AlessioNovi)\
**Post date:** [April 9, 2017, 11:01pm UTC](https://forum.freecodecamp.org/t/help-with-confirm-the-ending/104594/1 "2017-04-09T23:01:11Z")

</div>

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.

> <https://gist.github.com/AlessioNovi/d0b973f4297bc2fd174df630b0441573>

---

<div class="post-metadata">

**Author:** ![owel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/owel/32/48425_2.png) [@owel](https://forum.freecodecamp.org/u/owel)\
**Post date:** [April 10, 2017, 1:26am UTC](https://forum.freecodecamp.org/t/help-with-confirm-the-ending/104594/3 "2017-04-10T01:26:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AlessioNovi](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@AlessioNovi](https://forum.freecodecamp.org/u/AlessioNovi)\
**Post date:** [April 10, 2017, 1:05pm UTC](https://forum.freecodecamp.org/t/help-with-confirm-the-ending/104594/4 "2017-04-10T13:05:02Z")

</div>

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.

[https://gist.github.com/AlessioNovi/7ff9c1e7de5e50ed6430e52a22c12b07](https://gist.github.com/AlessioNovi/7ff9c1e7de5e50ed6430e52a22c12b07)

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

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:51pm UTC](https://forum.freecodecamp.org/t/help-with-confirm-the-ending/104594/6 "2021-01-17T20:51:54Z")

</div>

Closed on January 17, 2021, 8:51pm UTC


