Comparisons with the Logical And Operator not passing

Comparisons with the Logical And Operator not passing
0

#1

I’m pretty sure I’ve got this correct but when i click ‘Run the tests’ nothing happens. The same issue occurs on the challenge directly after this one with ( || ) also.

Any ideas on how to pass it?

Your code so far


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

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

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

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

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator


#2

When comparing values you must always have a value to compare. So

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

That 25 isn’t compared to anything so you need:

val >= 25

You also need an else in there.


#3

There is no need for an else.


#4

Awesome, this is working now. Thank you!

As Randell mentioned, an else statement is not needed in this challenge.


#5

huh…I never tried it without one :smiley:


#6

Well if condition doesn’t pass, next return statement get automatically executed and ends progam.