Confirm the Ending; works but not accepted

Confirm the Ending; works but not accepted
0.0 0

#1

I wrote this code that returns the correct answer for all the supplied scenarios, yet won’t give me the challenge complete. Suggestions?

Your code so far

function confirmEnding(str, target) {
  
if(target == str.substr(-(target.length))){
  return "true";
} else {
  return "false";
}
}

confirmEnding("He has to give me a new name", "name")

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36.

Link to the challenge:


#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#3

Your function should be returning a Boolean value (true or false) not a String value (‘true’ or ‘false’).


#4

"true" and "false" are not the same things as true and false.


#5

ah got it, thanks you two