Basic Algorithm Scripting - Confirm the Ending

Tell us what’s happening:
Describe your issue in detail here.

Your code so far



function logConfirmEnding(str, target) {
 
if (str.substring(str.length-(target.length))===target)
{
  return true;}
  
  else 
  {return false;
 }
}

function confirmEnding(str, target) 
{return logConfirmEnding(str, target);}
confirmEnding("Bastian", "n");
  

Your browser information:

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

Challenge: Basic Algorithm Scripting - Confirm the Ending

Link to the challenge:


Blockquote

for this challenge,I used the code above and it passed on Mozilla MDN interpretor ,but on freecodecamp doesn’t .

Please use some formatting when posting code .

I don’t understand why you have two separate functions?

Can you be more specific about which test cases are failing?

I tried this code and it passed now,the second function just to log “true” ,“false”

  • confirmEnding("Bastian", "n") should return true.
  • Passed:confirmEnding("Congratulation", "on") should return true.

  • Passed:confirmEnding("Connor", "n") should return false.

  • Passed:confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") should return false.

  • Passed:confirmEnding("He has to give me a new name", "name") should return true.

  • Passed:confirmEnding("Open sesame", "same") should return true.

  • Passed:confirmEnding("Open sesame", "sage") should return false.

I really recommend refactoring your code to simplify and follow conventional formatting.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.