Tell us what’s happening:
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(10);
`
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(10);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36.
Challenge: Comparison with the Greater Than Operator
The “Tell us what’s happening” section is for you to ask a question, or tell use about the behaviour of your code.
If you use the Get Help button in the lessons, it will prepopulate the Your code so far section with your code so far; there is no need to paste your code again.
Your third if statement is what’s causing the problem.
You don’t technically need it, because the first if statement will check if val is greater than 100, if it is not, your code will move to the second if statement and check if val is greater than 10. If val is not greater than 10, we know it must be less than 10, and so a simple return "10 or under" will work here.
Additionally, the thrid if statement is checking for the wrong thing. All of your test cases are greater than 0, and so will all return "10 or under"