Why else statement isn't working

Tell us what’s happening:
I console.log the str.substring(target) but it output the whole string instead of just the. target. I am trying to check why my else statement isn’t working. what is it I am doing wrong/missing?

   **Your code so far**

function confirmEnding(str, target) {
console.log(str.substring(target))
if(str.substring(target)){
  return true
}else{
  return false
}
 return str;
}

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

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36.

Challenge: Confirm the Ending

Link to the challenge:

I do not think that substring works the way you think it works.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring

I read it and from my understanding this is what it does . It takes the starting index and end index (not included in the result) e.g. mahassan.substring(0,2) will return ma ?

so the if statement says "if it is true then return true otherwise return false

Then why are you passing the target string in instead of a number?

If i do console.log(str.substring(target).length) it return a number but we don’t need a number, we need the word so target would return the word. Am I missing something?

You can only pass a number into substring. The variable target is a string, not a number. Therefore, you cannot get meaningful results by passing target into substring.

That’s right, @JeremyLT. I would recommend you, @mahassan, to use .indexOf() to find out what the index of the second argument is and then use that value as a parameter to .substring (). It is a way to do this.