Tell us what’s happening:
The solution used .slice() to solve this. Can someone explain how that worked? And what are the pro or cons of using regexes instead of .slice() in this situation?
Your code so far
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
const regex = RegExp(target + "\$");
return regex.test(str);
}
confirmEnding("Bastian", "n");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge: