Why $ character isn't matching my end of string?

Tell us what’s happening:
Hi guys,

I don’t understand why this code does not work. To my understanding $ is an expression that let me match any RegExp at the end of the string. So why this code returns false? Thanks!

Your code so far


function confirmEnding(str, target) {
var regex = /(target)$/;
var evaluate = regex.test(str);
return evaluate; 
}

confirmEnding("Bastian", "n"); //returns false

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0.

Challenge: Confirm the Ending

Link to the challenge:

try the same but with the regex cosntructor.

const regex = new RegExp(value, "gi");

I’m sorry but I don’t know how to use constructors yet

then you can’t use a regex here

if you want to use regex you need to use a constructor to make a regex from a variable

or you need to find a different way