Basic Algorithm Scripting - Confirm the Ending

Is there any instance where this doesn’t work/ is this bad practice?

function confirmEnding(str, target) {
str=str.split(target);
console.log(str);
if(str[str.length-1]!=‘’){
return false
}
return true;
}

confirmEnding(“Bastian”, “n”);

function confirmEnding(str, target) {
str=str.split(target);
console.log(str);
if(str[str.length-1]!=''){
return false
}
return true;
}

confirmEnding("Bastian", "n");

Challenge: Basic Algorithm Scripting - Confirm the Ending

Link to the challenge:

i wouldn’t have done it that way, but it works for me. i don’t know the etiquette tho, sorry.