What's wrong in this code

Tell us what’s happening:

Your code so far


function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var x = str.split("");
if(x[x.length-1] === target){
return true;
}else{
  return false;

}

}

confirmEnding("Congratulation", "n");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36.

Challenge: Confirm the Ending

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending

and if target is more than one character? like "tion"?
you are just checking the last letter of the string, and it fails if target is longer than 1