Comparisons with the Logical And Operator Not Working

Hi. I have gone over my code repeatedly and cannot find where I have gone wrong. Please could someone point me in the right direction?

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

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

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

I also tried the following for the end bit;

   return "Yes";
 }
 return "No"'

**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/comparisons-with-the-logical-and-operator

![error%3F|666x500](upload://96UVv7TQe1osaDGMiBafJYjy1rD.png)

I had it out at first but added it in trying to fix something else. Thank you that did the trick. Really appreciate it @camperextraordinaire

When you put a semi-colon in, JavaScript assumes that is the end of a statement and does not treat the part in { } as code that should only execute if the condition is true. Instead, the part in the { } just executes as a stand alone block of code.

1 Like

Thank you for such a detailed reply. I’ll keep this in mind now.