Why wont my code work? (post again since can't find post)

function confirmEnding(str, target) {  
  var stringLength = str.length;
  var arrayString = str.split('');  
  if(arrayString[str.length - 1] === target){
    truth = true;
    return truth;
  } else {
    truth = false;
    return truth;
  }  
return truth;
};

confirmEnding("Bastian", "n");

Please explain to me why my answer will not work.

For some reason, the “alert()” method no longer works with FreeCodeCamp and
console.log() has never worked for me, but I have no problem outside of FreeCodeCamp.
With the recent website changes, it seems I can no longer test variable values.

Sorry if this doesn’t show correctly. I have done this in the correct format so it separates out
the code. Again, my apologies for this being hard to read. something is broken on the new FreeCodeCamp website. :frowning:

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 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

Are you declaring the variable truth anywhere?

Thank you for your input.
I see now that my “truth” variable had not been defined.

I think in the answer to the section, they might not have defined “truth” either
as a variable. It has been a while since I looked at this.

Thanks for the help!