Why won't my Confirm the Ending challenge code work

I think I am on to something,concerning the Confirm the Ending algorithm challenge. But I might be wrong.
It seems that I cant make my target.lenght turn negative. Think that would solve the challenge. Maybe not.
Is there a way to make a parameter value negative in the str.substr() method ? Check out my code please …




function confirmEnding(str, target) {
 var a = str.substr(-target.lenght, target.length);
if (a === target) {return true;}
  return false;
}

confirmEnding("Rana", "na");

I haven’t tested the code, but at first glance I see the typo at -target.lenght. Try changing it to -target.length.

1 Like

This is the second time I made this .length typo. Thanks!