** Hello guys, I have been battling with this challenge for whole day now. The two result below is not passing. please fellow campers what could possibly be wrong with my code.
confirmEnding(“Congratulation”, “on”) should return true:**
confirmEnding(“Open sesame”, “same”) should return true.
Your code so far
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
var splitWord = str.split("");
var splitWordNoQuote = str.split(" ");
var targetWord = target.split(" ");
var targetWordNoQuote = target.split(" ")
if (splitWord[splitWord.length-1] === targetWord[targetWord.length-1]) {
return true;
}
else if (splitWordNoQuote[splitWordNoQuote.length-1] === targetWordNoQuote[targetWordNoQuote.length-1]) {
return true; }
else{
return false;
}
// -- Falcor
return str;
}
confirmEnding("Bastian", "n");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending