Why this is not working whats wrong with it

Tell us what’s happening:
what’s wrong with this answer ?

Your code so far


function confirmEnding(str, target) {
if(str.test(/target$/)){
  return true ;
}{
  return false;
}

}

confirmEnding("Bastian", "n");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36.

Challenge: Confirm the Ending

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

inside that, it’s now looking for the regex string ending with “target”. within the regex, it doesn’t see that as a variable name.

Did you happen to read in the instructions…

But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.

1 Like