Problem withConfirm the Ending challenge

Tell us what’s happening:
return a should return true or false. no?

Your code so far

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  
  var len = str.length;
  var con = target.substring(target.length - len); 
  
  var a =  con === str;
  //return con === str;
  
  return a;
  
}

confirmEnding("Bastian", "n");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36.

Link to the challenge:

Why are you comapring con with str?

Because con is the last str words. Using the node console here when I compare them it outputs ‘true’

It does return true or false, but I think that you have str and target flipped in your understanding of the problem.

console.log(con, str)
n n

no surprises.

oh I figured out! I was testing my code on the terminal (with node) instead of in the browser, I must have confused str and target on the FCC page :s.

function confirmEnding(str, target) {
var endChars = str.substr(str.length - target.length);
return (endChars === target);
}

confirmEnding(“Bastian”, “n”);