Confirm The Ending False Positive

I’ve noticed one of the coding questions seems to be a little too easy to pass and I believe it could be fixed with a simple additional question.

consider this code

function confirmEnding(str, target) {

  for (let i = target.length, j = 0; i > 0; i--, j++) {
    if (str[str.length-i] == target[j]) {
      return true;
    } else {
      return false;

// an actual test

confirmEnding("Open sesame", "same");

This code will pass all the tests provided, even though, when the target is changed to for example “sage” it returns


I think a test should be added with some incorrect middle letters such as

confirmEnding("Open sesame", "sage");

testing if each individual letter is correct.

Let me know what you think or if I’m being silly!

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.