Basic JavaScript - Comparisons with the Logical And Operator

Tell us what’s happening:

I get the error message of you should have only one if statement, but when I remove one I get an error message on all of the tests, when I only had 2 with 2 if statements can I please get help here.

Your code so far

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

  if (val) {
    if (val<= 50 && val >= 2) {
      return "Yes";
    }
  }

  // Only change code above this line
  return "No";
}

testLogicalAnd(10);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Basic JavaScript - Comparisons with the Logical And Operator

Hi there!

The instructions is asking: Replace the two if statements with one statement, using the && operator, which will return the string Yes if val is less than or equal to 50 and greater than or equal to 25. Otherwise, will return the string No.

So you need only one if statement.

Hi @slightplyz

Replace the two if statements with one statement, using the && operator, which will return the string Yes if val is less than or equal to 50 and greater than or equal to 25 . Otherwise, will return the string No .

You should have only one if statement.
Also, check that both conditions are met.

Happy coding

With this code



I still get a ton of errors, even when I fix the 2 if statement issue. If need I can show the errors with 2 if statements.

The red squiggly line in your screenshot indicates you have a mismatch of curly braces.