Why won't my Confirm the Ending challenge code work

Why won't my Confirm the Ending challenge code work
0

#1

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");

#2

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


#3

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