Basic JavaScript - Comparisons with the Logical And Operator

Tell us what’s happening:
Describe your issue in detail here. says i cannot use “if” function twice so i delete the first function and it gives me a error code… had all ticks apart from if statement… confused to what i am doing wrong here

I am very new to coding and javascript so it could be very simple but im out of ideas seems like a coding issue with the first if statement

Your code so far

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

  if (val) {
    if (val > "25" && val <= "50") {
      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/112.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Comparisons with the Logical And Operator

Link to the challenge:

hello matteo99

first you can write numbers as numbers so you can delete the quotes " "
second you can delete one of the closing curly brackets }
third 25 should also be equal or smaller =>

hope this might help

unfortunately not letting me pass as i have more than one if statement but if i remove the if statement it produces a codex error

delete the first if statement and paste your updated code here so we can look further

(val)
{if (val => 25 && val <= 50)
return “Yes”;}

so far

error : SyntaxError: unknown: Unexpected token (14:19)

12 |
13 |

14 | testLogicalAnd(10);

dont delete the return “no” i would suggest you reset the lesson and start with just deleteing the first if statement with its curly brackets.

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

  if (val ____________________ {
    
      return "Yes";
    
  }

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

testLogicalAnd(10);

like so and then fill the blank space

1 Like

Thankyou I got it in the end with

if (val <= 50 && val >= 25) {
return “Yes”;
}

Very important to read the question carefully as it was very simple haha. Been doing this all day maybe it is time for a break :slight_smile: haha

yes dont forget the coffee :slight_smile:

1 Like