# Confirm The Ending challenge feedback please. :)

**URL:** <https://forum.freecodecamp.org/t/confirm-the-ending-challenge-feedback-please/34659>\
**Category:** General\
**Created:** [September 7, 2016, 12:18am UTC](https://forum.freecodecamp.org/t/confirm-the-ending-challenge-feedback-please/34659 "2016-09-07T00:18:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolaScriptura92](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/solascriptura92/32/120561_2.png) [@SolaScriptura92](https://forum.freecodecamp.org/u/SolaScriptura92)\
**Post date:** [September 7, 2016, 12:18am UTC](https://forum.freecodecamp.org/t/confirm-the-ending-challenge-feedback-please/34659/1 "2016-09-07T00:18:24Z")

</div>

Hello fellow coders! I would like your feedback on this challenge that I just completed. I did it in less than an hour so I feel it’s not very simple and clean. Any ideas on how I can make it better? Any feedback would be great! Good or bad! I really want to learn good techniques. My code is below:  
function confirmEnding(str, target) {  
/\* check target against str by counting amount of letters in target and checking characters in str\*/  
//compare ending characters of str with characters in target.  
var stringLength = str.length;  
var targetLength = target.length;  
var strArray = str.split("");  
var targetArray = target.split("");  
var j = 0;  
//start comparing value from the length of string minus length of target

for (var i = (stringLength - targetLength); i \< str.length; i++) {  
if(strArray[i] === targetArray[j]) {  
j++;  
return true;  
}  
else return false;  
}  
}

confirmEnding(“Bastian”, “n”);

---

<div class="post-metadata">

**Author:** ![eddyw](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/eddyw/32/11676_2.png) [@eddyw](https://forum.freecodecamp.org/u/eddyw)\
**Post date:** [September 7, 2016, 1:03am UTC](https://forum.freecodecamp.org/t/confirm-the-ending-challenge-feedback-please/34659/2 "2016-09-07T01:03:00Z")

</div>

In the challenge, they ask you to use one of the Javascript substring methods.

- [String.prototype.substr()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr)
- [String.prototype.substring()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)

I suggest you read the documentation and learn about them.  
A hint:  
`"Sebastian".substr(-3) // returns "ian" "ian".length //returns 3 confirmEnding("Sebastian", "ian") // <- You can implement the hint I gave you in this function.`

The [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference) is your friend 😉

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 5:29am UTC](https://forum.freecodecamp.org/t/confirm-the-ending-challenge-feedback-please/34659/3 "2021-01-16T05:29:28Z")

</div>

Closed on January 16, 2021, 5:29am UTC


