Basic Algorithm Scripting - Confirm the Ending

function confirmEnding(str, target) {

return str.slice(str.length - target.length) === target;
}

confirmEnding(“He has to give me a new name”, “name”);

Please the above is the code for confirming the end of a string. The instruction expects the code to return true but the above code will return a string. Pls I need clarification

Thank you. I just realized how it would return a Boolean

Interesting way to solve it, I didn’t think of that one!
I figured regex would’ve been the best solution, both ways seems pretty solid thou =)

I did:

function confirmEnding(str, target) {
return (str.match(${target}$) == target);
}
confirmEnding(“Bastian”, “n”);