I am trying to work out how to use the $ at the end of a regex that is passed to the new RegExp() method from a function argument. My code:
function confirmEnding(str, target) {
let r = new RegExp(target, 'i'); // need to make regex only identify pattern at the end
if (r.test(str) == true) {
return true;
} else {
return false;
}
}