Confirm the Ending - Why won't my code pass tests?

Confirm the Ending - Why won't my code pass tests?
0

#1

Tell us what’s happening:

Why isn’t my code passing the tests? Any help appreciated. I thought str.length -1 gets the last value in the string.

Your code so far


function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  let strSplit = str.split(" "); // [B,a,s,t,i,a,n]
  if (strSplit.length -1 === target) {
    return true;
  }else{
    return false;
  }
}

confirmEnding("Bastian", "n");

Your browser information:

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

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


#2

You are comparing a number with character/s.

So it will probably always false.