Tell us what’s happening:
How come this regular expression doesn’t work to test if the ending of the string is the target string?
Your code so far
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
let isThisTheEnd = /target$/;
if (isThisTheEnd.test(str) === true) {
return true;
}
else {
return false
}
}
console.log(confirmEnding('Bastian','n'));
confirmEnding("Bastian", "n");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending