freeCodeCamp Challenge Guide: Confirm the Ending

Why so complicated? Any compare operator returns true or false, so we don’t need no additional true-false.
Just:
return str.substring(str.length - target.length) === target;

43 Likes