Confirm the Ending - issue

Tell us what’s happening:
I’m not quite sure why this is not working, after checking the solution for this problem I find it much simpler, but still I want to get this C-like code working for some reason!

  **Your code so far**

function confirmEnding(str, target) {
let strArr = [...str];
let strCheck = [...target];

let j = 0;
for( let i = ( strArr.length - strCheck.length ); i < strArr.lenght; i++  ) {
    if( strArr[i] != strCheck[j] )
      return false;
    j++; 
}

return true;
}

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

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

Challenge: Confirm the Ending

Link to the challenge:

Be careful with what you are writing

1 Like