Basic JavaScript - Comparison with the Greater Than Operator

Tell us what’s happening:
Despite changing the number below to test the if statements will return correctly for both if statements and for "10 and under, it will not return an “Over 100” statement. It only says “10 and under” no matter which number I input. What is wrong with this? I have even reset the question multiple times.

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";
}


testGreaterThan(50);
console.log(testGreaterThan());

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Comparison with the Greater Than Operator

Link to the challenge:

There doesn’t seem to be anything wrong with your code.

The issue is in the way you are checking:
change console.log(testGreaterThan()); to console.log(testGreaterThan(50));
to see what happens. Then change the 50 to 5 and then to 500

Thank you. Let me try this right now!

Double-check your code, make sure you’re using the right comparison operators (> ), and try running it again with different numbers to see if the conditions are returning as they should.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.