Basic Javascript tutorial: logical 'and' operator - test not letting me pass

Tell us what’s happening:
I have done everything correctly (it even shows correctly when I put my code into a different code editor) but on freecodecaamp it keeps returning that it’s not correct.
The test run results says :
You should use the && operator once (which I have)
You should have only one if statement (which I have)

all the console.logs when I run the test show the correct /expected values

I tried using <=50 && >= 25 as well as >=25 && <=50 (see below)

The task asked me to replace the two if statements with one statement, using the && operator, which will return "Yes" if val is less than or equal to 50 and greater than or equal to 25 . Otherwise, will return "No" .

The original test page showed this:

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

  if (val) {
    if (val) {
      return "Yes";
    }
  }

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

testLogicalAnd(10);

Your code so far

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

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

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

console.log(testLogicalAnd(10));//console shows No
console.log(testLogicalAnd(0));//console shows No
console.log(testLogicalAnd(24));//console shows No
console.log(testLogicalAnd(25));//Yes
console.log(testLogicalAnd(30));//Yes
console.log(testLogicalAnd(50));//Yes
console.log(testLogicalAnd(51));//No
console.log(testLogicalAnd(75));//No
console.log(testLogicalAnd(80));//No
```js

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

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

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

console.log(testLogicalAnd(10));//console shows No
console.log(testLogicalAnd(0));//console shows No
console.log(testLogicalAnd(24));//No
console.log(testLogicalAnd(25));//Yes
console.log(testLogicalAnd(30));//Yes
console.log(testLogicalAnd(50));//Yes
console.log(testLogicalAnd(51));//No
console.log(testLogicalAnd(75));//No
console.log(testLogicalAnd(80));//No

I think Your Code Is correct
Let Me check it

I checked It And It Is Correct @newby

Your Code Is correct, Please check it or there must be a net issue on your side

Thank you - i can’t believe how quickly I received an answer!!
I just reset it all (again!) and this time it worked.
i think it didn’t like me adding so many console.logs!
this time I just entered different values one at a time

Thank you - i can’t believe how quickly I received an answer!!
I just reset it all (again!) and this time it worked.
this time I just entered different values in the console.log one at a time instead of writing multiple console.logs …maybe that made a difference?

Welcome, newby.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).


Also, it appears you have edited out useful information in the pre-formatted post, before you posted it. Be careful to leave the code and other information as is, and only add information below the Tell us what’s happening section.

Cheers

uhhh…No. It wanted that first it will check val >= 25 and then val <= 50

And when i opened the forum then i saw your post.

I am available 15 hours in day. If you need Help Then just mention me like @abeergoel8

thank you @Sky020 …I’ll try to remember that next time!

thank you @abeergoel8 I really, really appreciate your offer!