Comparison with the Greater Than Operator - Need Correction

Tell us what’s happening:
While I am doing this code challenge, one condition getting failed but technically it’s correct. Because as a backend developer we used to have a constant number (value) on the left side. :slight_smile:

This is my code:

function testGreaterThan(val) {
  if (100 < val) {  // Change this line
    return "Over 100";
  }
  
  if (10 < val) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(100);

You should use the > operator at least twice --> This line getting failed. Then I changed my code like below then it gets passed. Can I suggest edit in this post? Or technically am I doing anything wrong?

Your code so far

function testGreaterThan(val) {
  if (val > 100) {  // Change this line
    return "Over 100";
  }
  
  if (val > 10) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(100);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/comparison-with-the-greater-than-operator

1 Like

The challenge tests are strict. They expect val > xxx instead of xxx < because the challenge said to use the greater then operator

1 Like

While your function worked correctly, the specific challenge was to use the ‘greater than’ (>) operator, which is why your solution with the ‘less than’ operator did not pass.

1 Like