Need help!Confirm the Ending

Tell us what’s happening:
why won’t this work?

Your code so far


function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  var check = /str$/;
  return (check == true )? true:false;

}

confirmEnding("Bastian", "n");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending

You have twice the opening of the function, that may cause some issues, or it was an error copying and pasting

Then, with /str$/, if used correctly, you are literally matching “str” at the end of your string (btw, you want target at the end of str)

And you may want to review the regex section from the beginning, you are not using anything correctly.

var check = /str$/;, here check is just equal to /str$/ and so it will never be equal to true.

For extras infos, You can transform a string in a regular expression using this:

Also, return (check == true )? true:false; a comparison is already returning a bolean, you don’t need the ternary operator. If you write
let i = 10; return i > 0; it will already return true without anything else needed

yes, I realised the mistake