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.

Does not accept logically equivalent answer

See original GitHub issue

Describe the Issue

When I write the loop as:

  for (let i = 0; i < len; i++) {
    console.log(firstFive[i]);
  }

the response is evaluated to be correct. But similar approach and logically equivalent approach like:

  for (let i = 0; i <= len-1; i++) {
  // Only change code above this line
    console.log(firstFive[i]);
  }

is rejected.

In first loop, I converted<=to<to solve OBOE problem. In second loop, I changed the value i is being compared with like i <= len-1

both are acceptable approaches but the response is not accepted in case of 2nd approach.

Affected Page

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing

Your code

function countToFive() {
  let firstFive = "12345";
  let len = firstFive.length;
  // Only change code below this line
  for (let i = 0; i <= len-1; i++) {
  // Only change code above this line
    console.log(firstFive[i]);
  }
}

countToFive();

Expected behavior

Code should be considered as valid and must be accepted.

Screenshots

No response

System

Device: HP 255 g7
OS: Manjaro Linux
Browser: Mozilla Firefox
Version: 101.0.1

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
jeremyltcommented, Aug 3, 2022

Personally, I don’t think we need to add every single possible way to accomplish this task. The current regex handles the majority of learner solutions. This extra case should handle the overwhelming majority of learner solutions. We can add more if they become necessary.

2reactions
moT01commented, Aug 2, 2022

File with the code.

I was going to suggest we reword the instructions, but I think it would be fine to account for both of these possible variations. Here’s a regex I made quick: i\s*<\s*len\s*;|i\s*<=\s*len\s*-\s*1\s*;

Screen Shot 2022-08-02 at 10 52 33 AM

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logical Equivalences
The first method to show that two statements and p and q are equivalent is to build a truth table to to find...
Read more >
2.2: Logically Equivalent Statements - Mathematics LibreTexts
Two expressions are logically equivalent provided that they have the same truth value for all possible combinations of truth values for all ...
Read more >
Logical Form And Logical Equivalence
The negation of a conjunction (logical AND) of 2 statements is logically equivalent to the disjunction (logical OR) of each statement's negation. That...
Read more >
Why are the following not logically equivalent?
With that interpretation, for all x the antecedent is true because for any x in the domain {0,1} either P is true or...
Read more >
Logical Equivalence (Explained w/ 13+ Examples!)
This means we can also say that If Ryan does not take Allison to dinner, then he did not get a pay raise...
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