question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code lets pass user even if code is wrong because of inadequate number of cases

See original GitHub issue

Challenge Confirm the Ending has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  var b=3;
  str = str.split('');
  target = target.split('');
  if(target.length ==1 && target[0] != str[str.length-1])
    return false;
   if(target.length ==1 && target[0] == str[str.length-1])
    return true;
  for(i=0;i<target.length;i++) {
  if (target[target.lenghth-i] == str[str.length-i])
    b++;
  }
  if(i==b )
    return true;
  else 
    return false;

}

confirmEnding("dename", "game");

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Bounceycommented, Oct 24, 2016

Oh wow! @praveenoswal17 thanks for finding this bug, it seems so obvious when looking at it now.

But what an edge case to highlight it 👍 😄

First-timers only!

Add another test that should return true, but with a target.length > 4.

The code for this challenge lies here.

Following CONTRIBUTING.md will help you get set up with a local development environment, so you can test your changes.

If you have any issues whilst working on this, checkout the Contibutors Chat Room. Everyone here has been through the process of setting up and submitting their first PR to freeCodeCamp and can help with many issues you may come across.

Good luck and Happy Coding! 👍

0reactions
systimoticcommented, Oct 24, 2016

@praveenoswal17 I should clarify. Currently, checking the one length targets, returning true for the 4 length answers and returning false for everything else. Another passing solution would be to only check if the last two characters match. Adding a test that should return true with a target length larger than four fixes the first issue, but it doesn’t help the second issue. A test like I suggested in my previous comment should help with that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forbidden (403), Unauthorized (401), or What Else?
401 Unauthorized is the status code to return when the client provides no credentials or invalid credentials.
Read more >
Input validation errors: The root of all evil in web ...
Missing or improper input validation is a major factor in many web security vulnerabilities, including cross-site scripting (XSS) and SQL ...
Read more >
Codestudio Contest 12 Editorial | Live Problem Solving | Striver
Check our Website: https://www.takeuforward.org/In case you are thinking to buy courses, please check below: Link to get 20% additional ...
Read more >
Quiz: Plagiarism | Academic Integrity - University of Guelph
The following multiple-choice quiz tests your knowledge of what is and what is not considered to be plagiarism, as well as of strategies...
Read more >
10 Common Web Security Vulnerabilities
Don't suffer through a security breach—take action before any problems arise. Master these 10 common web security vulnerabilities now.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found