** Help Needed ** Confirm the Ending

Link to challenge:

My code:

function confirmEnding(str, target) {
  return str.substring(-target.length) === target;
}

confirmEnding("Bastian", "n");

What’s wrong with my code? What am I missing?

Try

function confirmEnding(str, target) {
  console.log(str.substring(-target.length));
  return str.substring(-target.length) === target;
}

Javascript isn’t exactly like Python here.

1 Like

HI @danielanggggg !

I would also take a look at the examples they give in the docs under the section called " Using substring() with length property"

It will help you see where the error is.

1 Like