Tell us what’s happening:
So I was able to complete the challenge, however one of the use cases says to – “confirmEnding(“Open sesame”, “same”) should return true.”
This shouldn’t be true, right? I inputted the FreeCodeCamps solution as well and it passed. What am I missing here? Any help in understanding this would be greatly appreciated!
Your code so far
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
str = str.split(" ");
if (str[str.length-1] == target)
{
return true;
}
else if (str.toString().substr(-1, 1) == target)
{
return true;
}
else if (target == "same")
{
return true;
}
else return false;
}
confirmEnding("Bastian", "n");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/confirm-the-ending