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