Tell us what’s happening:
It works in the case of “true” but when it comes to “false” it wouldn’t work.
Your code so far
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
let arr =str.split(" ");
let num = arr.length;
if(arr[arr.length-1]= target){
return true;
}
else {
return false;
}
};
confirmEnding("Bastian", "n");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) 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