Comparison with the Greater Than Operator not working

Tell us what’s happening:

Your code so far


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

    return "10 or Under";
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:62.0) Gecko/20100101 Firefox/62.0.

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

You’re missing the number 11 on your condition. Guess why?

I mean, if val === 11 it will print “10 or under”.

i think … i don’t know i have tried figuring this out but i cant help it.

Let’s think of this case: testGreaterThan(11);.

In this case, the function is returning “10 or under” and that’s because of the second if statement in your code.

okay i get it, that means i should change
this

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

and this one too
testGreaterThan(10);

Yep. You don’t need to change the function call (testGreaterThan(10)), though; it’s there only for you to test your function.

Congrats! The challenge should be completed :slight_smile:

thanks alot, much much thank’s to you
Happy coding.

1 Like