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.

commenting out the second if statement returns a failed test. The test should pass as the commented out if statement has no bearing on the return statement.

See original GitHub issue

Challenge Comparisons with the Logical And Operator has an issue. User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


function testLogicalAnd(val) {
  // Only change code below this line

  if (val<=50 && val>=25) {
    //if (val) {
      return "Yes";
    }
  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(10);

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ryzokukencommented, Sep 18, 2016

Evidently, the code counting the number of ifs does not pay any regard to the fact if it is commented or not, it’s just plain old counting the number of ifs present inside your code.

EDIT: Even writing something as stupid as // what if triggers the test case.

EDIT2: Aha! As i thought, the statement for the test case is:

assert(code.match(/if/g).length === 1, 'message: You should only have one <code>if</code> statement');

Which is basically just counting the number of ifs in your code. Maybe we could improve it to disregard ifs inside a commented block.

0reactions
Bounceycommented, Oct 25, 2016

A PR to fix this will be raised against #11360

Read more comments on GitHub >

github_iconTop Results From Across the Web

How should one comment an if-else structure? [duplicate]
If it is needed to comment if else statements, I prefer to describe the case what made the code reach that point. Especially...
Read more >
Error with IF connecting to IFS statement
Hey! Im having an error with an excel task. So im got a RANDBETWEEN(1,10) and if said.
Read more >
Curious Perversions in Information Technology - The Daily WTF
[quote user="sys<in"] Another possibility is that the value of I has no bearing in the commented-out parts, but the condition else can only...
Read more >
Google C++ Style Guide
If the #include was replaced with forward decls for B and D , test() would call ... Variables needed for if , while...
Read more >
IF Statement Excel – If Function Examples - freeCodeCamp
If you are analysing data in Excel and need to set the value of a cell conditionally, you can use an IF statement...
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