Basic Algorithm Scripting - Confirm the Ending

Tell us what’s happening:
Describe your issue in detail here.
hi i don’t know what is wrong with my code please can you help

Your code so far

function confirmEnding(str, target) {
  for (let i = str.length - target.length; i < str.length; i++) {
    if (str[i] != target[i-str.length]) {
      return false;
    }
  }
  return true;
} 

confirmEnding("Bastian", "n");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.43

Challenge: Basic Algorithm Scripting - Confirm the Ending

Link to the challenge:

i is always going to be less than str.length, right?

So what does that mean for i-str.length?

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.